tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ryan O'Hara <>
Subject Re: Initializing Parameter
Date Mon, 31 Jul 2006 18:57:33 GMT
> You are creating a ServletContextListener, which must be configured in
> the "listeners" section of your web.xml file: simply mention the
> ServletContextListener in there, and the contextInitialized() method
> will be called when the webapp is initialized (i.e. once for the  
> life of
> the webapp).
> If you restart Tomcat, your webapp will be initialized again during
> startup and your code will execute again.
> -chris

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  
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.



Chris and David,

Fantastic, thanks so much.  I'll give this a shot and see how it  
goes.  Your advice has been extremely helpful.  Thanks again!


To start a new topic, e-mail:
To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message