duplicated request for servlet outputting PDF

Discussion in 'Java' started by kevin, Jun 4, 2004.

  1. kevin

    kevin Guest

    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?
     
    kevin, Jun 4, 2004
    #1
    1. Advertising

  2. 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
     
    Andrew Thompson, Jun 4, 2004
    #2
    1. Advertising

  3. kevin

    Andy Fish Guest

    "kevin" <> wrote in message
    news:...
    > 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
     
    Andy Fish, Jun 4, 2004
    #3
  4. kevin

    kevin Guest

    "Andy Fish" <> wrote in message news:<9r1wc.215$>...
    > "kevin" <> wrote in message
    > news:...
    > > 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.
     
    kevin, Jun 5, 2004
    #4
  5. kevin

    Guest

    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
     
    , Jun 6, 2004
    #5
  6. 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
     
    Andrew Thompson, Jun 6, 2004
    #6
  7. kevin

    kevin Guest

    Andrew Thompson <> wrote in message news:<3vi5fng5i03w$.1c41lx1mp3wej$>...
    > 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
     
    kevin, Jun 7, 2004
    #7
  8. On 7 Jun 2004 03:28:29 -0700, kevin wrote:
    > Andrew Thompson <> 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, Jun 7, 2004
    #8
  9. >> Andrew Thompson <> 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
     
    Andrew Thompson, Jun 7, 2004
    #9
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. fredd00

    outputting doc or pdf files from sql

    fredd00, Sep 3, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    403
    Mark Rae
    Sep 3, 2005
  2. circuit_breaker
    Replies:
    2
    Views:
    2,012
    Jack Jia
    Apr 4, 2004
  3. Replies:
    3
    Views:
    29,128
    Stuart Wood
    Jun 6, 2006
  4. Ricardo Pog
    Replies:
    1
    Views:
    433
    Austin Ziegler
    Mar 26, 2008
  5. Outputting to PDF simply?

    , May 19, 2009, in forum: Perl Misc
    Replies:
    3
    Views:
    134
    bobmct
    May 20, 2009
Loading...

Share This Page