Is it possible to execute a servlet when Tomcat starts up? I'm trying to do some connection pooling with datasource connections. When Tomcat starts up I want to create a single connection instance and initialize some settings.
The best thing to do in those cases is use a context listener. Any class that implements javax.servlet.ServletContextListener will have to implement two methods, one of which is contextInitialized. In there, would be the best place to do your setup.
If you still want a servlet, then you can configure the servlet to 'load-on-startup' in web.xml.
Hey cool! They got a blimp! But I have a tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss