xmlgraphics-fop-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Jacobson <jacobson.mar...@gmail.com>
Subject Re: Relative paths when running FOP as servlet (Tomcat)
Date Wed, 25 Aug 2010 12:00:34 GMT
This is what I would do...

0) move the config file to be part of the war file, inside WEB-INF

1) web.xml

<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE web-app
    PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
    "http://java.sun.com/j2ee/dtds/web-app_2.3.dtd">

<web-app>
    <display-name>cartoWeb - vector map server</display-name>

	<context-param>
		<param-name>configuration-file</param-name>
		<param-value>WEB-INF/fop.xconf</param-value>
	</context-param>

	<listener>
		<listener-class>com.emc.carto.web.servlet.WebAppInitializer</listener-class>
	</listener>
...

2) Listener

public class WebAppInitializer implements ServletContextListener
{
	ServletContext ctx = null;

	public void contextInitialized(ServletContextEvent sce)
	{
		ctx = sce.getServletContext();
		String configFileName = ctx.getInitParameter("configuration-file");
		String realConfigFile = ctx.getRealPath(configFileName);
               try {
                     fopFactory.setUserConfig(new File(realConfigFile));
              }
etc.


HTH
Martin




On 25 August 2010 14:25, Esse <esse@widenarrow.se> wrote:
>
> Hi fopusers!
>
> Specs:
> Latest fop (1.0)
> Latest tomcat (7.x)
>
> I’m using the fop servlet example in tomcat, with a config file.
>
> Right now, FOpServlet is modified like this:
>
> protected void configureFopFactory() {
>        try {
>                fopFactory.setUserConfig(new File("/conf/fop.xconf"));
>        } catch (SAXException e) {
>                System.out.println(e);
>        } catch (IOException e) {
>                System.out.println(e);
>        }
>    }
>
> However, the path for the config file in the above example is
> C:\conf\fop.xconf .
>
> How to make config file path relative(in jar/war/tomcat folder?
>
> Really anywhere would do except a hard path, like [JAVA_HOME]/conf/fop.xconf
> or something like that.
>
>
> Please help :)
>
>
> --
> View this message in context: http://old.nabble.com/Relative-paths-when-running-FOP-as-servlet-%28Tomcat%29-tp29531194p29531194.html
> Sent from the FOP - Users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org
>
>



-- 
>From my MacBook Pro

---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org


Mime
View raw message