Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Servlet genereate PDF called twice

Reply
Thread Tools

Servlet genereate PDF called twice

 
 
Dev
Guest
Posts: n/a
 
      04-08-2004
Hi all, I have a web page, and in a link, with a JavaScript I open a new
window, then I change the url of the new window.

the new URL is a servlet call.

The response of the servlet is a PDF.

The problem is that servlet was called twice!
In the form on the page where there are the javascript there are no action
attribute.

I have tried to open the new window with
var vNewWin = window.open("/servlet/PrintPDFServlet?param.....",
name,option);
but the browser try to download a page /servlet/PrintPDFServlet?param.....
but witout success.

Anyone have some idea?

Thanks in advance.

Dev


 
Reply With Quote
 
 
 
 
Michael Scovetta
Guest
Posts: n/a
 
      04-08-2004
I would suggest checking it with wfetch (from Microsoft). See exactly
what is being sent and what is being received. Is the servlet being
init()ed correctly? If it throws an exception, it'll re-init(). Are
you calling it from a forward() or something internal as well as from
/servlets/... ? I've had this only happen once, and it was actually my
Tomcat filters executing twice-- once for the request to / and once
for the request to /index.jsp (it was my default page setup in
web.xml).

It might also be a content-type issue-- is any other data being sent
as well as the PDF?

Hope that help a bit.

Michael Scovetta


"Dev" <(E-Mail Removed)> wrote in message news:<c53aqr$2ofs8j$(E-Mail Removed)-berlin.de>...
> Hi all, I have a web page, and in a link, with a JavaScript I open a new
> window, then I change the url of the new window.
>
> the new URL is a servlet call.
>
> The response of the servlet is a PDF.
>
> The problem is that servlet was called twice!
> In the form on the page where there are the javascript there are no action
> attribute.
>
> I have tried to open the new window with
> var vNewWin = window.open("/servlet/PrintPDFServlet?param.....",
> name,option);
> but the browser try to download a page /servlet/PrintPDFServlet?param.....
> but witout success.
>
> Anyone have some idea?
>
> Thanks in advance.
>
> Dev

 
Reply With Quote
 
 
 
 
Clemens Martin
Guest
Posts: n/a
 
      04-08-2004
Hi,

is the content-type set correctly in the HttpServletResponse
(application/pdf, i think)?
Which kind of servlet-engine and version?
I also think to remember there is some thing with HTTP header "no-cache" and
such things, try to google for that.

Try to figure out if it's the same problem in Netscape and/or IE and google
again.

Hope that helps a little bit,

Clemens Martin


"Dev" <(E-Mail Removed)> schrieb im Newsbeitrag
news:c53aqr$2ofs8j$(E-Mail Removed)-berlin.de...
> Hi all, I have a web page, and in a link, with a JavaScript I open a new
> window, then I change the url of the new window.
>
> the new URL is a servlet call.
>
> The response of the servlet is a PDF.
>
> The problem is that servlet was called twice!
> In the form on the page where there are the javascript there are no action
> attribute.
>
> I have tried to open the new window with
> var vNewWin = window.open("/servlet/PrintPDFServlet?param.....",
> name,option);
> but the browser try to download a page /servlet/PrintPDFServlet?param.....
> but witout success.
>
> Anyone have some idea?
>
> Thanks in advance.
>
> Dev
>
>



 
Reply With Quote
 
Dev
Guest
Posts: n/a
 
      04-09-2004

"Michael Scovetta" <(E-Mail Removed)> ha scritto nel
messaggio news:(E-Mail Removed) om...
> I would suggest checking it with wfetch (from Microsoft). See exactly
> what is being sent and what is being received. Is the servlet being
> init()ed correctly?


Yes

>If it throws an exception, it'll re-init().


No exceoption rised

>Are you calling it from a forward() or something internal as well as from
> /servlets/... ?


I call a servlet from Javascript code: I set the window.location.href to
/servlet/printPDFServlet?param1=qqqq&param2=...


>I've had this only happen once, and it was actually my
> Tomcat filters executing twice-- once for the request to / and once
> for the request to /index.jsp (it was my default page setup in
> web.xml).
>
> It might also be a content-type issue-- is any other data being sent
> as well as the PDF?


I have set the content-type to apllication/pdf

>
> Hope that help a bit.
>
> Michael Scovetta
>


Thanks

Federico.


 
Reply With Quote
 
Jayaram
Guest
Posts: n/a
 
      04-09-2004
Dev,
Are you using Internet Explorer ? There is a bug in IE that causes the
browser to automatically send two requests for a dynamically generated
PDF document. You would notice that this doesnt happen in Netscape
browsers.
The workaround in IE is to use the html emebd tag:

<EMBED src="your servlet url" contentType = "application/pdf">

(the syntax above may not be correct - find out more about this on an
HTML reference guide)

Regards,
J...


"Dev" <(E-Mail Removed)> wrote in message news:<c53aqr$2ofs8j$(E-Mail Removed)-berlin.de>...
> Hi all, I have a web page, and in a link, with a JavaScript I open a new
> window, then I change the url of the new window.
>
> the new URL is a servlet call.
>
> The response of the servlet is a PDF.
>
> The problem is that servlet was called twice!
> In the form on the page where there are the javascript there are no action
> attribute.
>
> I have tried to open the new window with
> var vNewWin = window.open("/servlet/PrintPDFServlet?param.....",
> name,option);
> but the browser try to download a page /servlet/PrintPDFServlet?param.....
> but witout success.
>
> Anyone have some idea?
>
> Thanks in advance.
>
> Dev

 
Reply With Quote
 
Dev
Guest
Posts: n/a
 
      04-09-2004

"Jayaram" <(E-Mail Removed)> ha scritto nel messaggio
news:(E-Mail Removed) m...
> Dev,
> Are you using Internet Explorer ?


Yes!

>There is a bug in IE that causes the
> browser to automatically send two requests for a dynamically generated
> PDF document. You would notice that this doesnt happen in Netscape
> browsers.
> The workaround in IE is to use the html emebd tag:
>
> <EMBED src="your servlet url" contentType = "application/pdf">
>
> (the syntax above may not be correct - find out more about this on an
> HTML reference guide)


Tanks a lot.

> Regards,
> J...


Good Easter!

Dev (Aka Federico)



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Postscript to PDF with pdf-tools, pdf-writer, or other Sean Nakasone Ruby 1 04-14-2008 09:13 PM
PDF::Writer, create pdf and insert in other pdf file. Ricardo Pog Ruby 1 03-26-2008 08:24 PM
Servlet.service() for servlet jsp threw exception java.lang.IllegalStateException: getOutputStream() has already been called for this response javadev Java 5 11-16-2006 11:22 AM
servlet called twice Dev Java 5 05-03-2004 09:08 PM
Servlet question(Tomcat, web.xml, servlet-class, servlet-name) circuit_breaker Java 2 04-04-2004 03:26 AM



Advertisments