tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mgai...@hotmail.com
Subject Re: apache fop remains active in servlet environment
Date Thu, 29 Nov 2007 13:56:49 GMT
FOP 0.94 has working servlet code
which can be called specifying the xml and xsl
http://servername/fop/servlet/FopServlet?xml=data.xml&xslt=format.xsl

OR just using the fo param
http://servername/fop/servlet/FopServlet?fo=readme.fo

http://archive.apache.org/dist/xmlgraphics/fop/binaries/
M--
----- Original Message -----
Wrom: YRWTQTIPWIGYOKSTTZRCLBDXRQBGJS
To: <users@tomcat.apache.org>
Sent: Thursday, November 29, 2007 6:25 AM
Subject: apache fop remains active in servlet environment


>
> I use apache fop in a servlet to display some xml as pdf. When I have used
> that functionality in my webapp my (Tomcat 6.0) web container doesn't want
> to undeploy. It deletes everything in the webapps/*context* directory
except
> WEB-INF/lib/batik.jar and WEB-INF/lib/fop.jar. When trying to delete the
> files manually windows tells me they are in use.
>
> I use this code to render the xml into pdf
>
> ByteArrayOutputStream out = new ByteArrayOutputStream();
> FopFactory ff=FopFactory.newInstance();
> TransformerFactory tf=TransformerFactory.newInstance();
>
> StreamSource xslfo=new
> StreamSource(this.getServletContext().getRealPath("lid-pdf.xsl"));
> try {
> Transformer tt=tf.newTransformer(xslfo);
> Fop fp=ff.newFop(MimeConstants.MIME_PDF, out);
>
> SAXResult res=new SAXResult(fp.getDefaultHandler());
> Source src= new DOMSource(doc);
> DOMResult dd=new DOMResult();
> assert(src!=null);
> assert(res!=null);
> tt.transform(src, dd);
>     Transformer t2=tf.newTransformer();
>    // System.out.println(res.getNode().getFirstChild());
>     t2.transform(new DOMSource(dd.getNode()), res );
>
>     //Prepare response
>     response.setContentType("application/pdf");
>     assert(out.size()>0);
>     response.setContentLength(out.size());
>   //  System.out.println(Version.getVersion());
>     //Send content to Browser
>     response.getOutputStream().write(out.toByteArray());
>     response.getOutputStream().flush();
>     out.close();
>
> } catch (FOPException e) {
> // TODO Auto-generated catch block
> throw new ServletException(e);
> } catch (TransformerConfigurationException e1) {
> // TODO Auto-generated catch block
> throw new ServletException(e1);
> } catch (TransformerException e) {
> // TODO Auto-generated catch block
> throw new ServletException(e);
> }
>
> System.gc();
>
>
> Anyone has any ideas?
>
> Roel
> --
> View this message in context:
http://www.nabble.com/apache-fop-remains-active-in-servlet-environment-tf489
6511.html#a14023743
> Sent from the Tomcat - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message