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

=============

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!

-Ryan

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to