Setting Environment Variable for Tomcat 6 Servlet

Posted by amaevis on Server Fault See other posts from Server Fault or by amaevis
Published on 2011-01-14T22:18:48Z Indexed on 2011/01/14 22:55 UTC
Read the original article Hit count: 152

Filed under:
|

I'm using Ubuntu's default installation of Tomcat 6. I'm deploying a ROOT.war, and trying to set an environment variable specific to it, i.e. accessible from System.getenv() in the Servlet.init(config).

According to the docs (http://tomcat.apache.org/tomcat-6.0-doc/config/context.html), I can specify this in a Context element in conf/Catalina/localhost/ROOT.xml. I've created that with these contents:

<Context>
  <Environment name="FOO" value="bar" type="java.lang.String" override="false"/>
</Context>

And I've deployed the webapp as usual, i.e. to webapps/ROOT.war.

Server.getenv("FOO") in the Servlet.init(config) still returns null. What am I missing?

© Server Fault or respective owner

Related posts about ubuntu

Related posts about tomcat6