Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Java (http://www.velocityreviews.com/forums/f30-java.html)
-   -   duplicated request for servlet outputting PDF (http://www.velocityreviews.com/forums/t134100-duplicated-request-for-servlet-outputting-pdf.html)

kevin 06-04-2004 03:29 PM

duplicated request for servlet outputting PDF
 
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?

Andrew Thompson 06-04-2004 03:46 PM

Re: duplicated request for servlet outputting PDF
 
On 4 Jun 2004 08:29:55 -0700, kevin wrote:

> ...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

--
Andrew Thompson
http://www.PhySci.org/ Open-source software suite
http://www.PhySci.org/codes/ Web & IT Help
http://www.1point1C.org/ Science & Technology

Andy Fish 06-04-2004 04:28 PM

Re: duplicated request for servlet outputting PDF
 
"kevin" <kevin@mtel.co.uk> wrote in message
news:6675f17.0406040729.3dbf37b6@posting.google.co m...
> 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



kevin 06-05-2004 07:10 PM

Re: duplicated request for servlet outputting PDF
 
"Andy Fish" <ajfish@blueyonder.co.uk> wrote in message news:<9r1wc.215$Vy6.6236380@news-text.cableinet.net>...
> "kevin" <kevin@mtel.co.uk> wrote in message
> news:6675f17.0406040729.3dbf37b6@posting.google.co m...
> > 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


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.

mromarkhan@rogers.com 06-06-2004 03:10 AM

Re: duplicated request for servlet outputting PDF
 
Peace.

kevin wrote:


> 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?



Here is another wild, untested, unproven, random poke.
response.addHeader("Cache-Control", "private");

Have a good day.

-- References
http://bugs.php.net/bug.php?id=19450&edit=2

Andrew Thompson 06-06-2004 05:24 AM

Re: duplicated request for servlet outputting PDF
 
On 5 Jun 2004 12:10:39 -0700, kevin wrote:

> ..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.

--
Andrew Thompson
http://www.PhySci.org/ Open-source software suite
http://www.PhySci.org/codes/ Web & IT Help
http://www.1point1C.org/ Science & Technology

kevin 06-07-2004 10:28 AM

Re: duplicated request for servlet outputting PDF
 
Andrew Thompson <SeeMySites@www.invalid> wrote in message news:<3vi5fng5i03w$.1c41lx1mp3wej$.dlg@40tude.net> ...
> On 5 Jun 2004 12:10:39 -0700, kevin wrote:
>
> > ..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.


: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

Andrew Thompson 06-07-2004 10:55 AM

Re: duplicated request for servlet outputting PDF
 
On 7 Jun 2004 03:28:29 -0700, kevin wrote:
> Andrew Thompson <SeeMySites@www.invalid> wrote in message news:...
>> On 5 Jun 2004 12:10:39 -0700, kevin wrote:

...
(yada, yada)
>> Please put more effort into your questions.

>
> :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. :-)

--
Andrew Thompson
http://www.PhySci.org/ Open-source software suite
http://www.PhySci.org/codes/ Web & IT Help
http://www.1point1C.org/ Science & Technology

Andrew Thompson 06-07-2004 11:11 AM

Re: duplicated request for servlet outputting PDF
 
>> Andrew Thompson <SeeMySites@www.invalid> wrote in message news:...

[snip..]
> (yada, yada)
>>> Please put more ....


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.. ;-)

--
Andrew Thompson
http://www.PhySci.org/ Open-source software suite
http://www.PhySci.org/codes/ Web & IT Help
http://www.1point1C.org/ Science & Technology


All times are GMT. The time now is 01:20 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.