ServletContext域
1、生命周期监听接口:ServletContextListener
①contextInitialized(ServletContextEvent sce) 创建ServletContext时调用
②contextDestroyed(ServletContextEvent sce) 销毁ServletContext时调用
2、属性监听接口:ServletContextAttributeListener
①attributeAdded(ServletContextAttributeEvent scae) 添加属性时调用
②attributeRemoved(ServletContextAttributeEvent scae) 移除属性时调用
③attributeReplaced(ServletContextAttributeEvent scae) 修改属性时调用
HttpSession域
3、生命周期监听接口:HttpSessionListener
①sessionCreated(HttpSessionEvent se) 创建session时调用
②sessionDestroyed(HttpSessionEvent se) 销毁session时调用
4、属性监听接口:HttpSessionAttributeListener
①attributeAdded(HttpSessionBindingEvent se) 添加属性时调用
②attributeRemoved(HttpSessionBindingEvent se) 移除属性时调用
③attributeReplaced(HttpSessionBindingEvent se) 修改属性时调用
ServletRequest域
5、生命周期监听接口:HttpSessionListener
①requestInitialized(ServletRequestEvent sre) 创建request时调用
②requestDestroyed(ServletRequestEvent sre) 销毁request时调用
6、属性监听接口:HttpSessionAttributeListener
①attributeAdded(ServletRequestAttributeEvent srae) 添加属性时调用
②attributeRemoved(ServletRequestAttributeEvent srae) 移除属性时调用
③attributeReplaced(ServletRequestAttributeEvent srae) 修改属性时调用
7、感知监听接口:HttpSessionBindingListener
实现了HttpSessionBindingListener接口的JavaBean对象可以感知自己被绑定到Session中和从 Session中删除的事件,不需要在web.xml注册
①valueBound(HttpSessionBindingEvent event) 对象绑定到session时调用
②valueUnbound(HttpSessionBindingEvent event) 对象从session中删除时调用
8、HttpSessionActivationListener:钝化、活化监听器
实现了HttpSessionActivationListener接口的JavaBean对象可以感知自己被活化(反序列化)和钝化(序列化)的事件,不需要在web.xml注册
①sessionDidActivate(HttpSessionEvent se)
②sessionWillPassivate(HttpSessionEvent se)