How can get a static class to be initialized when the Tomcat JVM is started?

Alex Chaffee

The great thing about statics is that they're initialized whenever the class is loaded. So since you can't use a class without loading it, you know that just using your personalized cache will cause it to be loaded and initialized if necessary.

That said, there are many reasons not to use a static. You may be safer using a regular object and sticking it in the application context.

See Where and how can I define an application level variable that gets initialized at container startup? and I want the servlet container to load one or more servlets when the container is first fired up, as opposed to when a client issues a request for the servlets. How do I do that under Servlet 2.2 API?