rivate TransformerFactory tFactory = TransformerFactory.newInstance();

public void init() throws ServletException {
    //Optionally customize the FopFactory and TransformerFactory here
}

[..]

    //Setup a buffer to obtain the content length
    ByteArrayOutputStream out = new ByteArrayOutputStream();

    //Setup FOP
    Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, out);

    //Setup Transformer
    Source xsltSrc = new StreamSource(new File("foo-xml2fo.xsl"));
    Transformer transformer = tFac