publicvoidattributeReplaced(HttpSessionBindingEvent sbe){ /* This method is invoked when an attibute is replaced in a session. */ } } package com.demo.servlet;
@WebListener() publicclassApplicationListenerimplementsServletContextListener, HttpSessionListener, HttpSessionAttributeListener{ TypeService tsService=new TypeService(); // Public constructor is required by com.demo.servlet spec publicApplicationListener(){ }
// ------------------------------------------------------- // ServletContextListener implementation // ------------------------------------------------------- publicvoidcontextInitialized(ServletContextEvent sce){ /* This method is called when the com.demo.servlet context is initialized(when the Web application is deployed). You can initialize com.demo.servlet context related data here. */ sce.getServletContext().setAttribute("typeList",tsService.GetAllType()); }
publicvoidcontextDestroyed(ServletContextEvent sce){ /* This method is invoked when the Servlet Context (the Web application) is undeployed or Application Server shuts down.
@WebListener() publicclassApplicationListenerimplementsServletContextListener, HttpSessionListener, HttpSessionAttributeListener{ TypeService tsService=new TypeService(); // Public constructor is required by com.demo.servlet spec publicApplicationListener(){ }
// ------------------------------------------------------- // ServletContextListener implementation // ------------------------------------------------------- publicvoidcontextInitialized(ServletContextEvent sce){ /* This method is called when the com.demo.servlet context is initialized(when the Web application is deployed). You can initialize com.demo.servlet context related data here.