I use eclipse + tomcat + maven.
When I deploy my project to Tomcat, the following entry gets added to the server.xml of the tomcat configuration:
<Context docBase="C:\ws_eclipse\ws\.metadata\.plugins\org.eclipse.wst.server.core\tmp1\wtpwebapps\MyApp" path="/myApp" reloadable="true" source="org.eclipse.jst.jee.server:MyApp"/>
What I actually want is to add an environment variable so that the context looks like this:
<Context docBase="C:\ws_eclipse\ws\.metadata\.plugins\org.eclipse.wst.server.core\tmp1\wtpwebapps\MyApp" path="/myApp" reloadable="true" source="org.eclipse.jst.jee.server:MyApp">
<Environment name="config.file" type="java.lang.String" value="C:/test/config.xml" />
</Context>
I tried adding it as an environment variable in eclipse run configuration, but when I deployed the application on tomcat, the context does not include the environment variable.
You could add a context.xml file in the META-INF directory of your webapp. The content of this file may look like:
This has the same effect as defining a
<context-param/>in your web.xml. UseServletContext.getInitParameter("config.file")to retrieve it’s value as a String.You may use
Environmentas well, but it’s probably overkill (You just need a String anyway, I think).See http://tomcat.apache.org/tomcat-6.0-doc/config/context.html