I've been using the FopServlet to build a prototype, but the first thing I did was to change in the
given FopServlet the way it retrieves this files (its dependant on the 'working directory' of your JVM) :
try replacing the doGet method of FopServlet with the one beside.
Then place your fo files in your <webapp-root-directory>/WEB-INF/fo


public void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException {
try {
String foParam = request.getParameter(FO_REQUEST_PARAM);
String xmlParam = request.getParameter(XML_REQUEST_PARAM);
String xslParam = request.getParameter(XSL_REQUEST_PARAM);

if (foParam != null) {
InputStream foInput = getServletContext().getResourceAsStream("/WEB-INF/fo/" + foParam);
renderFO(new InputSource(foInput), response);
} else if((xmlParam != null) && (xslParam != null)) {
File xslFile = new File(getServletContext().getRealPath("/WEB-INF/xsl/" + xslParam));
File xmlFile = new File(getServletContext().getRealPath("/WEB-INF/xml/" + xmlParam));
XSLTInputHandler input = new XSLTInputHandler(xmlFile, xslFile);
renderXML(input, response);
} else {
PrintWriter out = response.getWriter();
"<body><h1>FopServlet Error</h1><h3>No 'fo' "+
"request param given.</body></html>");
} catch (Exception ex) {
throw new ServletException(ex);

gary cor wrote:

Dear All,

I am up and running with my first ever servlets in Tomcat4.03 (although they only run in the examples folder). So, I put all five of the latest version of the jar files as instructed in FOP servlets into the lib directory ( avalon-framework-4.1.2.jar batik-all-1.5b1.jar fop-0.20.3rc.jar logkit-1.0.1.jar and xalan-2.3.1.jar) and complied servlets OK as well. However, following this I've tried everything I can think possible to make a servelt produce a pdf from fo and still no joy and very soar eyes now as well!

First I ran them without an fo file but they error as follows:
Results in:
"FopServlet Error
No 'fo' or 'xml/xsl' request param given."

So then I assume I it is just a case of not finding an file.fo but when I try to give in one


and it always causes a status 500 internal service error (maybe something to do with it running only in the examples folder I have no idea!). I also found a mail a while ago from the group saying to put the fo files in the C:\Apache-Tomcat\bin file but still I get the same errors.

Please can someone help?


PS. I have also found a servlet in saxon for FOP has anyone tried this out is it easier to get working!

Send and receive Hotmail on your mobile device: http://mobile.msn.com

Reply via email to