This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
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.