duplicated request for servlet outputting PDF

K

kevin

hi there,

i'm using the JFreeReport library to make PDF's from sql data, and
while it was placed inline into a frameset from JSP by a bean function
all was well. I moved the code to a servlet in a popup window, and now
i get (no matter *what* i try) two requests back to back for the data
(which beingh in a temp table is gone second try and i get no output).

the jsp builds a javascript entry when the servlet is ready to display
in the
data entry screen like
<%if (some local boolean) { %>
<SCRIPT language="JavaScript"
window.open("myservlet","report" "window parameters");
</SCRIPT>
<%}%>

I've tried
1 <EMBED src='myservlet' > with an intermediate page (called
crappyie.html)
2 renaming the servlet ref to servletref.pdf in web.xml
3 adding response.setHeader("Cache-Control", "\"no-cache\"");
4 adding response.setHeader("Cache-Control", "\"must-revalidate\"");
5 pulling my hair out


i did a full scan (by hand & using tools) of the headers coming in,
and all is the same except the first one has language header ...

doGet
header accept value */*
header accept-language value ie-ee,en-gb;q=0.5
header accept-encoding value gzip, deflate
header user-agent value Mozilla/4.0 (compatible; MSIE 6.0; Windows 98;
..NET CLR 1.0.3705; .NET CLR 1.1.4322)
header host value 192.168.254.99:8080
header connection value Keep-Alive
header cookie value JSESSIONID=539EB1780479A5F087E830765187DB44
content type null length -1

doGet
header accept value */*
header accept-encoding value gzip, deflate
header header user-agent value Mozilla/4.0 (compatible; MSIE 6.0;
Windows 98; .NET CLR 1.0.3705; .NET CLR 1.1.4322)
header host value 192.168.254.99:8080
header connection value Keep-Alive
header cookie value JSESSIONID=539EB1780479A5F087E830765187DB44
content type null length -1

I've run out of ideas except poking random values into the header to
see if one will stop the thing repeating. Anyone got a better idea?
 
A

Andrew Thompson

...I moved the code to a servlet in a popup window, and now
i get (no matter *what* i try) two requests back to back for the data
(which beingh in a temp table is gone second try and i get no output).

I am not sure, but this sounds suspiciously
similar to a common problem with JS in pure
HTML that relates to framsets and new windows.

Since I try to avoid both (especially new windows)
I never read the discussions, but it may be worth
Googling the comp.lang.javascript group for hints..
the jsp builds a javascript entry when the servlet is ready to display
in the
data entry screen like
<%if (some local boolean) { %>
<SCRIPT language="JavaScript"
window.open("myservlet","report" "window parameters");
</SCRIPT>

...and that JS is wrong to start with.

For starters you forgot the closing '>'
and the ..
language='JavaScript'
...should be..
type='text/javascript'

Learn up on JavaScript before you wonder
why JS embedded in JSP that opens new
windows does not work as expected.

I think the validator would have pointed
out some of those errors as well..
<http://validator.w3.org/>

HTH
 
A

Andy Fish

kevin said:
hi there,

i'm using the JFreeReport library to make PDF's from sql data, and
while it was placed inline into a frameset from JSP by a bean function
all was well. I moved the code to a servlet in a popup window, and now
i get (no matter *what* i try) two requests back to back for the data
(which beingh in a temp table is gone second try and i get no output).

are you sure it's not something to do with the way the acrobat reader is
handling the view. Here's something I have seen happen before when using IE
with plugins.

firstly the browser starts downloading the stream, then it realises it is a
content-type that should be handled by an external application, so it closes
the stream and fires up the external app giving it the URL. the external
viewer then makes the request again and downloads the document.

is it possible you changed the actobat/IE integration so that instead of
firing up in emdedded mode it now fires up a separate window, or made some
other change to IE or pdf reader's settings?

if it definitely isn't this, then I've wasted your time and I have no idea
how it could be related to javascript pop-up windows.

Andy
 
K

kevin

Andy Fish said:
are you sure it's not something to do with the way the acrobat reader is
handling the view. Here's something I have seen happen before when using IE
with plugins.

firstly the browser starts downloading the stream, then it realises it is a
content-type that should be handled by an external application, so it closes
the stream and fires up the external app giving it the URL. the external
viewer then makes the request again and downloads the document.

is it possible you changed the actobat/IE integration so that instead of
firing up in emdedded mode it now fires up a separate window, or made some
other change to IE or pdf reader's settings?

if it definitely isn't this, then I've wasted your time and I have no idea
how it could be related to javascript pop-up windows.

Andy

I will look in javascript groups for duplication / misdirection type
issues. and explore setting the frameset page to the servlet output to
see if that changes anything.
The extrapolation of the jsp / javascript for the newsgroup might not
compile in a jsp engine but it was a too hurriedly made sample to show
how the window is opened, not the actual source. thanx for all
feedback even if only on my typing in google 8). The code behind the
pdf output *works fine right now* when called directly from a jsp page
that makes no text output,as part of the frameset. I moved the code
generating the pdf to a servlet, and *now* it duplicates requests. I
know the window open command is only executed once, because i put an
alert in front of it. several other posts have mentioned specifically
dynamic pdf output from a servlet exibiting strange duplication of GET
requests and only in ie6.
 
A

Andrew Thompson

..it was a too hurriedly made sample to show
how the window is opened, not the actual source.

This reads to your audience like..

"I'm too busy and important to accurately
specify my problem, why don't you spend
several hours trying to figure it out,
draft a complete reply, then I'll let
you know how you got the understanding
of my problem wrong.'

Please put more effort into your questions.
 
K

kevin

Andrew Thompson said:
This reads to your audience like..

"I'm too busy and important to accurately
specify my problem, why don't you spend
several hours trying to figure it out,
draft a complete reply, then I'll let
you know how you got the understanding
of my problem wrong.'

Please put more effort into your questions.

:oops:

I do appologise. I know how much people care to even answer these
posts, so I am very grateful to you and others, especially you as you
found the problem.

I changed the code to pop up a new window with a jsp in it. This jsp
now calls a bean function that redirects to the pdf producing servlet,
and it indeed only executes once. I did add the

response.setHeader("Cache-Control", "\"private\"");

but this did not work. thankyou. :D
 
A

Andrew Thompson

...
(yada, yada)
:oops:

I do appologise. ...

Recognising that it might have been
taken badly is more than enough.
Entirely forgiven.
I changed the code to pop up a new window with a jsp in it. This jsp
now calls a bean function that redirects to the pdf producing servlet,
and it indeed only executes once.

Excellent! Glad you resolved it. :)
 
A

Andrew Thompson

[snip..]
(yada, yada)

I seem to have stuffed the attributions in
the last post.. It was *me* with the
'yada yada' that I snipped. Though of
course, most of the regulars here would
have guessed that.. ;-)
 

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

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top