监听对象:request session application
1、监听器
开发步骤:a.编写监听器,实现接口 b.配置web.xml
a.监听对象的创建和销毁
request:ServletRequestListener
session:HttpSessionListener
applicat:ServletContextListener
每个监听器 各自提供了2个方法:监听开始、监听结束方法
ServletContext在servlet容器启动时自动创建
b.监听对象中属性的变更
request:ServletRequestAttributeListener
session:HttpSessionAttributeListener
applicat:ServletContextAttributeListener
Session的钝化和活化:
钝化:内粗->硬盘
活化:硬盘->活化
session对象的四种状态:
监听session对象的绑定和解绑:HttpSessionBindingListener
a.session.setAttribute(“a”,xxx) 对象a【绑定】到session中
b.session.removeAttribute(“a”) 将对象a从session中【解绑】
监听session对象的钝化、活化:HttpSessionActivationListener
c.钝化
d.活化