1对象作用域:
request对象作用范围:一次请求范围内
session对象作用范围:一次回话范围内
servletContext对象作用范围:整个web应用程序
2 servletContext对象的监听:
1)ServletContextListener接口
a)void contextInitialized(ServletContextEvent sce):程序开始时监听
b)void contextDestroyed(ServletContextEvent sce):程序销毁时监听
在web.xml中注册:
<listener>
<listener-class></listener-class>
</listener>
2)ServletContextAttributeListener接口:
//增加属性
a)void attributeAdded(ServletContextAttributeEvent arg0)
//删除属性
b)void attributeRemoved(ServletContextAttributeEvent arg0)
//修改属性
c)voidattributeReplaced(ServletContextAttributeEvent arg0)
在web.xml中注册:
<listener>
<listener-class></listener-class>
</listener>