You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Johnny <ke...@mimos.my> on 2002/06/24 11:26:51 UTC
how to set environment variable in tomcat?
to all the tomcat users,
if i want to set my own environment variable for my application running in
tomcat, what should i do? do i have to edit the server.xml?
in jserv, we using "ApJServEnvVar" for defining the environment variable in
jserv.conf, so how about tomcat?
regards
johnny.
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: how to set environment variable in tomcat?
Posted by Jacob Kjome <ho...@visi.com>.
Hello Johnny,
Use <context-param>'s in your web.xml.
For instance:
<context-param>
<param-name>databaseUrl</param-name>
<param-value>jdbc:postgresql:msrd</param-value>
</context-param>
Context parameters can be added to your web.xml near the top of the
file after <display-name> and <description>
You can reference your parameters by doing this:
String myparameter = (String) context.getInitParameter("databaseUrl");
You can also use parameters for specific servlets:
<servlet>
<servlet-name>log4j-init</servlet-name>
<servlet-class>org.enhydra.barracuda.core.util.logging.Log4jInit</servlet-class>
<init-param>
<!-- relative path to config file within current webapp -->
<param-name>log4j-config</param-name>
<param-value>WEB-INF/log4j.xml</param-value>
</init-param>
</servlet>
And retrieve that by using the following in the init() method of said
servlet:
String configPath = getInitParameter("log4j-init");
You can also retrieve stuff from JNDI using Context Resources which
are specified in the server.xml. I'll let you read up on that in the
Tomcat docs.
Does that help?
Jake
Monday, June 24, 2002, 4:26:51 AM, you wrote:
J> to all the tomcat users,
J> if i want to set my own environment variable for my application running in
J> tomcat, what should i do? do i have to edit the server.xml?
J> in jserv, we using "ApJServEnvVar" for defining the environment variable in
J> jserv.conf, so how about tomcat?
J> regards
J> johnny.
J> --
J> To unsubscribe, e-mail: <ma...@jakarta.apache.org>
J> For additional commands, e-mail: <ma...@jakarta.apache.org>
--
Best regards,
Jacob mailto:hoju@visi.com
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>