2 Minutes To Code (β Version)

Apache Tomcat - 2 minute tutorial

How to configure servlets to run automatically on tomcat webserver start-up

If you need to do some sort of initialization (create db pool, http connection thread pool etc. ) before your servlet can receive http requests from clients, this can be done by using the element <load-on-startup> with a value of 1 as shown below in the deployment descriptor(web.xml).

When the webserver deploys your web-app (.war file), it will load all servlets that have a load-on-startup of 1.