HttpSessionListener:一旦,进入一个网站,这个网站就自动为浏览器分配一个session,调用sessionCreated(),当session过期或销毁时候,调用sessionDestroyed,这时候有两种方法:session.invalidate();和等待session自动过期。
#session过期时间,时间单位是一分钟,并且只能是整数,如果是零或负数,那么会话就永远不会超时。 public void sessionCreated(HttpSessionEvent arg0) {} public void sessionDestroyed(HttpSessionEvent arg0) {} 例:http://www.blogjava.net/jzone/articles/284193.html HttpSessionAttributeListener:在向session增加、删除和修改属性时调用 public void attributeAdded(HttpSessionBindingEvent arg0) {} public void attributeRemoved(HttpSessionBindingEvent arg0) {} public void attributeReplaced(HttpSessionBindingEvent arg0) {}
HttpSessionActivationListener:分布式环境下Session激活和失活时调用 public void sessionDidActivate(HttpSessionEvent arg0) {} public void sessionWillPassivate(HttpSessionEvent arg0) {}
ServletContextListener:在一个application启动和结束时调用 public void contextDestroyed(ServletContextEvent arg0) {} public void contextInitialized(ServletContextEvent arg0) {} 例:http://www.cnblogs.com/jackyrong/archive/2006/09/04/494759.html http://www.qqgb.com/Program/Java/JavaBlog/Program_145756.html ServletContextAttributeListener:在向application增加、删除和修改 Attributes时调用 public void attributeAdded(ServletContextAttributeEvent arg0) {} public void attributeRemoved(ServletContextAttributeEvent arg0) {} public void attributeReplaced(ServletContextAttributeEvent arg0) {}
Powered by: BlogJava Copyright © Gavin.lee