servlet who starts with app starting,
A ServletContextListener can be used for that. When your app starts, the container(e.g.
Tomcat) creates a ServletContext object. And you can define a class that implements the ServletContextListener interface to detect the creation of the ServletContext object. The class will have two methods:
contextInitialized(ServletContextEvent event)
contextDestroyed(ServletContextEvent event)
If you put the name and location of your listener class in the web.xml file:
then the container will automatically create an object of your class and call the contextInitialized() method when your app starts.
Inside the contextInitialized() method you can write your one thread, two job program(whatever that means?
).
(The experts will most likely post about how that is the wrong way to organize your code and give you some better suggestions.)
[ October 10, 2006: Message edited by: sven studde ]