I build a web application with JSPs and in my servlet I have:
public class MyServlet extends HttpServlet {
protected void processRequest(HttpServletReque
In my point of view, a good way is to implement a Servlet Context Listener. It listens to application startup and shutdown.
public class YourListener implements javax.servlet.ServletContextListener {
public void contextInitialized(ServletContextEvent sce) {
}
public void contextDestroyed(ServletContextEvent sce) {
}
}
And then, you configure the listener in your web.xml () or with the @WebServletContextListener annotation.