I think Matt was saying that you *shouldn't* set no-cache in order to fix 
the problem of IE fetching twice.
However in my experience you need to set no-cache....

The following code is copied from an oldish posting by Matt himself....
I think the commented out bits are the ones you are thinking of....

Matt seemed to look into the possibility of setting a cache limit (eg 15 
minutes) but I couldn't see how to do that....

Alex


       ByteArrayOutputStream out = new ByteArrayOutputStream();

       org.apache.fop.apps.Driver driver = new org.apache.fop.apps.Driver();
       driver.setErrorDump(true);
       driver.setRenderer(driver.RENDER_PDF);
       driver.setupDefaultMappings() ;
       driver.setOutputStream(out);
       driver.render(foDoc);

       response.setContentType("application/pdf");
/*
       if (isIE4) {
//        response.setHeader("Cache-Control", "no-cache");
//        response.setHeader("Pragma", "no-cache");
       }
       else {
         response.setHeader("Cache-Control", "private");
       }
*/
       byte[] content =3D out.toByteArray();
       response.setContentLength(content.length);
       System.out.println("Content length = " + content.length + "\n");
       response.getOutputStream().write(content);
       response.getOutputStream().flush();

     }
     catch (Exception ex) { throw new ServletException(ex); }
   }


At 17:11 05/03/02, [EMAIL PROTECTED] wrote:
>how do you set the no-cache for the output header going out of the servlet,
>because I saw this prob just yesterday.
>
>----- Original Message -----
>From: "Savino, Matt C" <[EMAIL PROTECTED]>
>To: <[EMAIL PROTECTED]>
>Sent: Tuesday, March 05, 2002 11:34 AM
>Subject: RE: FO -> PDF works with Netscape, not with IE
>
>
> > If you don't set any of the cache properties in the response header
> > (returned PDF) to no-cache (or expires immediately, or whatever
>equivalent),
> > IE 5.5 is smart enough to internally return it's own cache on the second
>hit
> > (at least in my experience).
> >
> > Matt Savino
> >
> >
> > > -----Original Message-----
> > > From: Katiyar, Bhawana [mailto:[EMAIL PROTECTED]]
> > > Sent: Tuesday, March 05, 2002 7:37 AM
> > > To: [EMAIL PROTECTED]
> > > Subject: RE: FO -> PDF works with Netscape, not with IE
> > >
> > >
> > > I am using IE 5.5 SP2. My request for a PDF document is being
> > > sent twice.
> > > Does anyone has a working servlet which serves PDF requests
> > > in one shot.
> > >
> > > Thanks
> > > Bh
> > >
> > > -----Original Message-----
> > > From: Savino, Matt C [mailto:[EMAIL PROTECTED]]
> > > Sent: Monday, March 04, 2002 5:00 PM
> > > To: '[EMAIL PROTECTED]'
> > > Subject: RE: FO -> PDF works with Netscape, not with IE
> > >
> > >
> > > If you have to support older verisons of IE (<5.5), you'll
> > > also have to take
> > > a couple of steps to avoid calling FOP 2 or 3 times. One
> > > you'll want to look
> > > out for User-Agent='contype' in the request header, and only
> > > return the
> > > content type, not the actual content. But this isn't enough
> > > (even though
> > > Microsoft says it is). IE < 5 likes to request the PDF doc,
> > > then kill the
> > > request, then request the contype, then request the doc again. Except
> > > sometimes, and under no reproduceable set of conditions I
> > > could discern, IE
> > > accepts the whole document on the first request. Which means
> > > you can't just
> > > only call FOP and return the whole doc on the third hit. The only full
> > > solution I've seen so far is to cache the PDF byte-array in
> > > the session
> > > after the first hit, then return it if requested on the third
> > > hit. (credit
> > > Jim Urban I believe) This doesn't save you from sending the
> > > PDF out over the
> > > wire twice, but it does save calling FOP twice. And so far
> > > the latter has
> > > proven to be much more time and resource-consuming. I've attached the
> > > servlet I use to generate HTML and PDF. It's kind of a mess,
> > > but you should
> > > be able to find all the pieces.
> > >
> > > One note: it's possible setting the 'Content-Disposition' as
> > > described below
> > > may clear up the problem. I remember experimenting with
> > > Content-Disposition
> > > a long time ago, but I didn't like the way it brought up two
> > > consecutive
> > > 'Save As...' dialogs.
> > >
> > > Matt Savino
> > >
> > >
> > > > -----Original Message-----
> > > > From: Chetan Vig [mailto:[EMAIL PROTECTED]]
> > > > Sent: Monday, March 04, 2002 1:51 PM
> > > > To: [EMAIL PROTECTED]
> > > > Subject: Re: FO -> PDF works with Netscape, not with IE
> > > >
> > > >
> > > > Make sure you have the following set in your response
> > > >                  // CONTENT DISPOSITION ENSURES THAT IE
> > > > BROWSER RECOGNIZES
> > > > THE PDF
> > > >                   // BYTE STREAM AS A PDF FILE
> > > >                   // SOLUTION FOUND FROM MICROSOFT SUPPORT PAGE
> > > >                   // NO IMPACT FOR NETSCAPE BROWSER
> > > >                   response.addHeader("Content-Disposition",
> > > > "inline;filename=report.pdf");
> > > >                   response.setContentLength(contentSize);
> > > >
> > > > Chetan
> > > >
> > > >
> > > > Jim Urban wrote:
> > > >
> > > > > Be sure you set the content length, otherwise IE has
> > > > problems.  It also
> > > > > helps to call reset to clear any information in the HTTP
> > > > header before
> > > > > setting your content type or any other values.
> > > > >
> > > > > Jim
> > > > >
> > > > > > -----Original Message-----
> > > > > > From: Katiyar, Bhawana [mailto:[EMAIL PROTECTED]]
> > > > > > Sent: Monday, March 04, 2002 3:23 PM
> > > > > > To: [EMAIL PROTECTED]
> > > > > > Subject: FO -> PDF works with Netscape, not with IE
> > > > > >
> > > > > >
> > > > > > Hi! I am using version .18 to render PDF from XML. Rendering is
> > > > > > fine with Netscape, but doesn't work with IE.
> > > > > > Any clues?
> > > > > > Thanks
> > > > > > Bhawana
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > >
> > > ---------------------------------------------------------------------
> > > > > > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > > > > > For additional commands, email: [EMAIL PROTECTED]
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > >
> > > ---------------------------------------------------------------------
> > > > > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > > > > For additional commands, email: [EMAIL PROTECTED]
> > > >
> > > >
> > > >
> > > >
> > > ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > > > For additional commands, email: [EMAIL PROTECTED]
> > > >
> > > >
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > > For additional commands, email: [EMAIL PROTECTED]
> > >
> > >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, email: [EMAIL PROTECTED]
> >
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, email: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]

Reply via email to