servlet called twice

D

Dev

I have a form like this.

<form name="test" action="/servlet/PrintPdfServlet" method="post>
<a href="document.test.submit()">submit</a>
</form>

When I click on submit, if the method is post, the servlet was called, the
PDF generated, the response gived, but Acrobat not run.

If I set the form method to "get" the servlet was called twice and acrobat
will run with the pdf.

I use Internet Explorer 6.0 whith all updates and patches.

I have tryed to use embed and object tag but without success.

Anyone have some idea?

Thanks.

Federico.
 
A

Andrew Tyson

Dev said:
I have a form like this.

<form name="test" action="/servlet/PrintPdfServlet" method="post>
<a href="document.test.submit()">submit</a>
</form>

Hi,

I think that this relates to IE ignoring the MIME-TYPE in the header of the
HTTP response. It uses the file extension to associate the returned response
with an application. Other than messing with the registry one way we got
around the problem was to set up our action to have a .pdf suffix (we are
using Struts - but the result should be the same). This causes IE to launch
Adobe Acrobat.

Thanks and regards,
Andrew
 
D

Dev

Hi

I have tryed to open a new window called test.pdf and change the url to
/servlet/printServlet?para1=xxx&para2=yyy... but don't work.

Is your solution?

Regards.

Fede.
 
A

Andrew Tyson

I have tryed to open a new window called test.pdf and change the url to
/servlet/printServlet?para1=xxx&para2=yyy... but don't work.


In your web.xml you need to define the following;

<servlet>
<servlet-name>myservlet</servlet-name>
<servlet-class>foo.bar.MyServlet</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>myservlet</servlet-name>
<url-pattern>myservlet.pdf</url-pattern>
</servlet-mapping>

Then you can call the servlet thus in a JSP;

<form method="post" action="/myservlet.pdf?arg1=....&arg2=...."/>

Becaus IE uses the file extension it thinks that the action mapping is a PDF
document.

HTH,
AT
 
J

Joona I Palaste

Andrew Tyson said:
I think that this relates to IE ignoring the MIME-TYPE in the header of the
HTTP response. It uses the file extension to associate the returned response
with an application. Other than messing with the registry one way we got
around the problem was to set up our action to have a .pdf suffix (we are
using Struts - but the result should be the same). This causes IE to launch
Adobe Acrobat.

That's MS for you - when faced with a standard, they start finding out
ways to break it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,139
Latest member
JamaalCald
Top