目前 Servlet2.4和JSP2.0常用的有7个监听器接口,分为3类:
1. Servlet上下文进行监听(Application级):
用于监听 ServletContext 对象的创建和删除以及属性的添加、删除和修改等操作,该监听器需要用到如下两个接口类:
(1) ServletContextAttributeListener:监听对ServletContext 属性的操作,比如增加、删除、修改
attributeAdded(ServletContextAttributeEvent e) 添加属性时调用
attributeReplaced(ServletContextAttributeEvent e) 修改属性时调用
attributeRemoved(ServletContextAttributeEvent e) 删除属性时调用
(2) ServletContextListener:监听对ServletContext 对象的创建和删除
contextInitialized(ServletContextEvent sce) 服务器启动时调用
contextDestroyed(ServletContextEvent sc