Monday, January 18, 2010

Tomcat start context value

Using Context Element inside server.xml or Context file.

<Context path="/path" docBase="localPath" ...... >
<parameter name="resource_name" value="resource_path">
</Context>

Using web.xml
<env-entry>
<env-entry-name>paramName</env-entry-name>
<env-entry-type>java.lang.String(or any type)</env-entry-type>
<env-entry-value>paramValue</env-entry-value>
</env-entry>
Calling in java source code.
Context initCtx = new InitialContext();
String paramValue = (String) initCtx.lookup(paramName);

No comments:

Post a Comment