To be more specific my servlet does like decribed below. The generation of the html or org.w3c.document is done in two different classes. The class that generates the html is called just once, but the one that creates the org.w3c.document twice. The servlet is invoked like: http://localhost/servlet/report.pdf?type=1&firstDate=1.1.2000&lastDate=31.1.2000&html=0&Submit=submit
/** * Process the HTTP Get request */ public void doGet( HttpServletRequest request, HttpServletResponse response ) throws ServletException, IOException { read some parameters, if (to html) { get htmlstr (the html to send) response.setContentLength( htmlstr.length()); response.getOutputStream().print( htmlstr ); response.getOutputStream().flush(); } else { get doc (Document to transform in pdf and send) renderFO( doc, response, request ); } } /** * renders an FO inputsource into a PDF file which is rendered directly to * the response object's OutputStream */ public void renderFO( Document doc, HttpServletResponse response, HttpServletRequest request ) throws Exception { // Create the PDF. ByteArrayOutputStream out = new ByteArrayOutputStream(); MessageHandler.setOutputMethod( MessageHandler.NONE ); Driver driver = new Driver(); driver.setRenderer( Driver.RENDER_PDF ); driver.addElementMapping( "org.apache.fop.fo.StandardElementMapping" ); driver.addElementMapping( "org.apache.fop.svg.SVGElementMapping" ); try { driver.setOutputStream( out ); driver.render( doc ); } catch ( Exception ex ) { cat.error(ex); } finally { try { out.close(); } catch ( IOException e ) { } } byte[] content = out.toByteArray(); response.setContentLength( content.length ); response.setContentType( "application/pdf" ); response.addHeader( "Content-Disposition", "inline; filename=report.pdf" ); response.getOutputStream().write( content ); response.getOutputStream().flush(); } --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, email: [EMAIL PROTECTED]