I can see where this would be a problem if you're firing SAX events all the
way to FOP. I guess you could do it the new and improved way for IE>5 and
Netscape and the old way for IE 4.x. 

By the way have you benchmarked this method against the one I use, for small
and large reports? I would be very interested to know what you found. I
believe FOP pretty much converts everything to DOM (or is it SAX?) right off
the bat anyway, so I don't know what you gain other than saving some memory
space on your app server. I know when I first got FOP running, I tested DOM
input vs. SAX vs. file on a large report and saw almost no difference in
performance.

thx,
Matt

(By the way, if anyone is using my servlet as an example, DO NOT have the
user session or anything else which can change after init() as a class
variable. Oops. I'm fixing it now.)


> -----Original Message-----
> From: Jim Urban [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, January 03, 2002 10:31 AM
> To: [EMAIL PROTECTED]
> Subject: RE: Servlet called multiple times solved
> 
> 
> That works great for the way you are calling FOP.  However, I 
> am using the
> new improved method for calling FOP (see below).  Do you have a way of
> handling the duplicate calls which will work with this implementation?
> 
> Thanks,
> Jim
> 
>       public void renderFO(Transformer pdfTransformer, Source 
> iInputSource,
> HttpServletResponse uResponse)
>               throws java.io.IOException
>       {
>               try
>               {
>                       // -------
>                       // Clear the output buffer completely 
> before attempting to return a PDF
>                       // -------
>                       mHttpServletResponse.reset();
>                       // -------
>                       // Get the response output stream. and 
> set the content type to PDF
>                       // -------
>                       OutputStream out = uResponse.getOutputStream();
>                       uResponse.setContentType("application/pdf");
> 
>                       // -------
>                       // Create a FOP driver, set the logger,
>                       // set the ouput mode to PDF and set 
> the output stream.
>                       // -------
>                       Driver driver = new Driver();
>                       driver.setLogger(mLogger);
>                       driver.setRenderer(driver.RENDER_PDF);
>                       driver.setOutputStream(out);
>                       // -------
>                       // Create SAXResult based on FOP Driver 
> content handler
>                       // which will accept SAX events and 
> build FOP tree
>                       // -------
>                       Result saxResult = new 
> SAXResult(driver.getContentHandler());
> 
>                       // Use the Transformer to transform an 
> XML Source and
>                       // send the output to a Result object. 
> Implicitely it will
>                       // create the FOP tree by firing SAX events.
>                       pdfTransformer.transform(iInputSource, 
> saxResult);
> 
>                       // The user is already viewing the PDF!
>                       out.flush();
>                       out.close();
>               }
>               catch (TransformerException e)
>               {
>                       System.err.println("Unable to generate 
> PDF:  " + e.toString());
>               }
>       }
> 
> 
> 
> 
> -----Original Message-----
> From: Savino, Matt C [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, January 03, 2002 11:32 AM
> To: '[EMAIL PROTECTED]'
> Subject: Servlet called multiple times solved
> 
> 
> Thanks to David Frankson and the other members of this board, 
> I have finally
> fully solved the problem with IE calling FOP two or three 
> times problem. The
> first solution came from this:
> 
> http://support.microsoft.com/support/kb/articles/Q293/7/92.ASP
> 
> But if you read the fine print, you notice that IE only uses
> user-agent=contype on the second hit. That still leaves the 
> first and third
> hits calling FOP. There are some clues to tell the difference 
> betweent the
> first and third hits, so I was trying to only return the full 
> PDF on the
> third hit. The problem is that IE sometimes decides to be 
> content with only
> one hit, and sometimes it decides to make all three. There is 
> no apparent
> rhyme or reason to this decision. If you only return the 
> content-type on the
> first call when IE has decided to only make one call it just 
> sits there.
> Anyway, the second part of the solution was to cache the PDF 
> byte-array in
> the user's session and return it on any subsequent hits on 
> the first pass.
> As a key to test that the PDFs are truly the same, I use a 
> counter in the
> query string which is the time in milliseconds.
> 
> Anyway here's the code. As usual there's a bunch of extra stuff, but I
> figure it may help. Please ask if you have any questions.
> 
> -Matt
> 
>  <<ReportGeneratorServlet.java>>
> 
> 
> ---------------------------------------------------------------------
> 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