Thanks for the tip on IE behaving like this.  

I don't agree with the suggestion about using DOM to
build up a document.  Intuitively it does not make sense
to have Xalan parse the document out when the program that
constructs it knows the structure.  There are several 
problems with this, however:

(1) It is more convoluted to code DOM than dealing with strings.
(2) It will be slower.   Xalan does not use DOM to store
nodes in an xml document since it creates too many objects.
(3) It will take more memory since storing the document in
a DOM will use more memory than a StringBuffer.

-----Original Message-----
From: David Frankson [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, August 08, 2001 12:33 PM
Subject: Re: FOP Servlets being invoked twice

    As far as I know, IE has always done 2 requests per mime type that
doesn't handle internally.  See Article ID: Q293336 in the M$ knowledge
base.  Netscape and all others only do 1 request.  If anyone knows a
configuration that can get IE to behave, please let me know

I do suggest adding

response.addHeader("Content-Disposition", "inline;

it will fix some glitches in IE5.0,  and also have you considered using
Dom  Document rather than a string to pass your xml around?  It would
you from having to parse it twice when you go from your business object
Xalan, and from Xalan to FOP.


----- Original Message -----
From: "Alex Amies" <[EMAIL PROTECTED]>
Cc: "Tim Kearney" <[EMAIL PROTECTED]>
Sent: Wednesday, August 08, 2001 11:15 AM
Subject: FOP Servlets being invoked twice

> I have a problem with a servlet, which serves up pdf documents,
> invoking the servlet twice for every time I request the
> url using my browser.  The pdf document is produced
> correctly in both instances.  Anybody else seen this
> problem, know what it is, or have a constructive suggestion?
> The servlet gets data from a database, formats into xml,
> transforms it with Xalan, then again to a pdf, sending
> the content to a byte array where it is then written to
> the output stream.  Here is a code fragment:
> Writer writer = new StringWriter();
> // Get an xslt processor factory
> TransformerFactory tFactory = TransformerFactory.newInstance();
> // Create the 3 objects the XSLTProcessor needs to perform the
> transformation.
> ReportInfo reportInfo = getReportData(request,res);
> String xml = reportInfo.getXml();
> StringReader stringReader = new StringReader(xml);
> Source xmlSource  = new StreamSource(stringReader);
> Source xslSheet   = getXSLInput(reportInfo.getReportNo());
> StreamResult xmlResult = new StreamResult(writer);
> Transformer transformer = tFactory.newTransformer(xslSheet);
> // Perform the transformation.
> transformer.transform(xmlSource, xmlResult);
> // send output from xsl transformation to a string reader
> // create a input source containing the xsl:fo file which can be fed
> Fop
> Reader reader = new StringReader(writer.toString());
> writer.flush();
> writer.close();
> //set Driver methods to start Fop processing
> Driver driver = new Driver();
> driver.setRenderer("org.apache.fop.render.pdf.PDFRenderer",".14");
> driver.addElementMapping("");
> driver.addElementMapping("org.apache.fop.svg.SVGElementMapping");
> driver.addPropertyList("org.apache.fop.svg.SVGPropertyListMapping");
> // send pdf writer output to a byte array stream
> ByteArrayOutputStream baos = new ByteArrayOutputStream();
> PrintWriter printWriter = new PrintWriter(baos);
> driver.setWriter(printWriter);
> driver.buildFOTree(parser, new InputSource(reader));
> driver.format();
> driver.render();
> // send the bytes out to the servlet output stream
> res.setContentType("application/pdf");
> res.setContentLength(baos.size());
> long sixty = System.currentTimeMillis() + 60*1000;
> res.setDateHeader("Expires", sixty);
> baos.writeTo(res.getOutputStream());
> res.flushBuffer();
> ---------------------------------------------------------------------
> 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