Where are you getting the parameter from? Is it going to change a lot?
I store parameters in the server.xml in the <GlobalNamingResources>
section as <Environment> entries, and then retrieve them with a call to
this routine:
public static String getEnvironmentVariable( String envVarName,
String varDefault) {
String parm;
try {
InitialContext initCtx = new InitialContext();
if (initCtx == null) throw new Exception( "No Context
for database setting" );
Context envCtx = (Context) initCtx.lookup(
"java:comp/env" );
parm = (String) envCtx.lookup( envVarName );
} catch(Exception e) {
parm = varDefault;
}
return parm;
}
. These values don't change once the system is started, so it works for
me. You'll need to do something else if they can change at runtime.
Ryan O'Hara wrote:
One more question: What is the best method for retrieving the
values? Thanks again.
-Ryan
On Jul 31, 2006, at 2:47 PM, David Smith wrote:
ServletContextListener is a new feature of servlet spec 2.4 (tomcat
5.0.x, 5.5.x). The essential parts are:
1. write a class implementing the
javax.servlet.ServletContextListener interface. The interface
itself requires two methods -- contextInitialized() [see below] and
contextDestroyed().
2. Add the listener to your web.xml in a <listener> attribute.
3. Deploy your app and the contextInitialized() method below will be
executed once each time the webapp is started.
The servlet spec itself and the servlet api javadocs have complete
information on implementing this.
--David
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]