Hi, I have seen various posts about this but nothing definative about the solution. Here's the problem:
I am building a web application to deploy and have no idea whether the deployment site runs with Unix or Windows or which Servlet engine they use. In theory, this should not be a problem if I deploy the app as a web application with no hard-coded paths. This works well upto a point. My servlet does an XML transformation using an XML file and an XSL file. Next, the output is sent to FOP for rendering. Unfortunately, the images do not appear. The images (and xml/xsl files) are currently all stored in the web_app_root/WEB-INF directory. I can reference the xml/xsl files without hard-coding paths (see code below) but what about the images? Does anyone know how to do this? My xml file has a graphic like this: <HTRelitiveRef HTRRKey="2" HTRRType="Picture" HTRRID="centurion.jpg" HTRRLink="" HTRRVisible="F">centurion</HTRelitiveRef> Thanks for your help, Rakesh import javax.servlet.http.*; import javax.servlet.*; import org.xml.sax.InputSource; import javax.xml.transform.*; import javax.xml.transform.stream.StreamSource; import javax.xml.transform.sax.SAXResult; import java.io.*; import java.util.*; import org.apache.fop.apps.Driver; public class FopServlet extends HttpServlet { public static final String PDF_REQUEST_PARAM = "checklist"; public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { processRequest(req, res); } public void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { processRequest(req, res); } public void processRequest(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { ServletContext scntxt = this.getServletContext(); String pathToFile = scntxt.getRealPath("/WEB-INF"); File inputXMLFile = new File(pathToFile + "DataFile.xml"); File inputXSLFile = new File(pathToFile + "PDFTemplate1.xsl"); java.net.URL test = scntxt.getResource("/centurion.jpg"); res.setContentType("application/pdf"); org.apache.fop.configuration.Configuration.put("baseDir","C:/JRun4/servers/tutorial/fop-war/WEB-INF"); Driver driver = new Driver(); driver.setOutputStream(res.getOutputStream()); driver.setRenderer(Driver.RENDER_PDF); try { Transformer transformer = TransformerFactory.newInstance() .newTransformer(new StreamSource(inputXSLFile)); transformer.setParameter("myParam", req.getParameter(PDF_REQUEST_PARAM)); transformer.transform(new StreamSource(inputXMLFile), new SAXResult(driver.getContentHandler())); } catch (TransformerException e) { e.printStackTrace(); } catch (TransformerFactoryConfigurationError transformerFactoryConfigurationError) { transformerFactoryConfigurationError.printStackTrace(); } } } --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]