tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jacob Kjome <h...@visi.com>
Subject Re: how to set environment variable in tomcat?
Date Mon, 24 Jun 2002 14:55:24 GMT
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:   <mailto:tomcat-user-unsubscribe@jakarta.apache.org>
J> For additional commands, e-mail: <mailto:tomcat-user-help@jakarta.apache.org>



-- 
Best regards,
 Jacob                            mailto:hoju@visi.com


--
To unsubscribe, e-mail:   <mailto:tomcat-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:tomcat-user-help@jakarta.apache.org>


Mime
View raw message