import javax.servlet.ServletContextEvent;import javax.servlet.ServletContextListener;import javax.servlet.annotation.WebListener;import javax.servlet.http.HttpSessionAttributeListener;import javax.servlet.http.HttpSessionEvent;import javax.servlet.http.HttpSessionListener;import javax.servlet.http.HttpSessionBindingEvent;@WebListener()publicclassListenerimplementsServletContextListener,
HttpSessionListener, HttpSessionAttributeListener {// Public constructor is required by servlet specpublicListener(){}// -------------------------------------------------------// ServletContextListener implementation// -------------------------------------------------------publicvoidcontextInitialized(ServletContextEvent sce){/* This method is called when the servlet context is
initialized(when the Web application is deployed).
You can initialize servlet context related data here.
*/}publicvoidcontextDestroyed(ServletContextEvent sce){/* This method is invoked when the Servlet Context
(the Web application) is undeployed or
Application Server shuts down.
*/}// -------------------------------------------------------// HttpSessionListener implementation// -------------------------------------------------------publicvoidsessionCreated(HttpSessionEvent se){/* Session is created. */}publicvoidsessionDestroyed(HttpSessionEvent se){/* Session is destroyed. */}// -------------------------------------------------------// HttpSessionAttributeListener implementation// -------------------------------------------------------publicvoidattributeAdded(HttpSessionBindingEvent sbe){/* This method is called when an attribute
is added to a session.
*/}publicvoidattributeRemoved(HttpSessionBindingEvent sbe){/* This method is called when an attribute
is removed from a session.
*/}publicvoidattributeReplaced(HttpSessionBindingEvent sbe){/* This method is invoked when an attibute
is replaced in a session.
*/}}