Listen to the Lifecycle Listing 1. This listener class listens to the lifecycle events of the ServletContext. mport javax.servlet.ServletContextListener; import javax.servlet.ServletContextEvent; public class MyApplicationListener implements ServletContextListener { public void contextInitialized( ServletContextEvent cse) { System.out.println( "Application initialized"); } public void contextDestroyed( ServletContextEvent cse) { System.out.println("Application shut down"); } } |