1 package test.web; 2 3 import javax.servlet.*; 4 import javax.servlet.http.*; 5 6 19 public final class SimpleListener implements ServletContextListener, HttpSessionListener { 20 21 public SimpleListener() {} 22 23 24 public void contextInitialized(ServletContextEvent sce) { 25 sce.getServletContext().log("The servlet context has been initialized, the web application is ready to process requests."); 26 } 27 28 29 public void contextDestroyed(ServletContextEvent sce) { 30 sce.getServletContext().log("The servlet context is about to be shut down."); 31 } 32 33 34 public void sessionCreated(HttpSessionEvent hse) { 35 HttpSession session = hse.getSession(); 36 session.getServletContext().log("A session was created, id: " + session.getId()); 37 } 38 39 40 public void sessionDestroyed(HttpSessionEvent hse) { 41 HttpSession session = hse.getSession(); 42 session.getServletContext().log("A session was invalidated, id: " + session.getId()); 43 } 44 } | Popular Tags |