import javax.servlet.ServletRequestEvent;import javax.servlet.ServletRequestListener;//监听器[用于监听ServletRequest对象的产生和销毁]public class MyServletRequestListener implements ServletRequestListener { //产生 public void requestInitialized(ServletRequestEvent sre) { System.out.println("requestInitialized()"); } //销毁 public void requestDestroyed(ServletRequestEvent sre) { System.out.println("requestDestroyed()"); }}
<listener>
<listener-class>cn.itcast.web.listener.MyServletRequestListener</listener-class>
</listener>
>>创建和销毁:ServletContextListener,Web容器部署时产生,Web容器重新部署时销毁原ServletContext对象 >>属性变化:ServletContextAttributeListner application.setAttirbute("name","jack") setAttribute("name","liw") removeAttribute("name")