---
title: "Servlet的8大监听者"
author: "CB-13"
date: "2011-10-24T21:16:57Z"
tags: ["Servlet"]
categories: ["互联网"]
slug: "servlet-8"
draft: false
lastmod: "2011-10-24T21:19:03Z"
id: 1211632
url: "https://cb-13.iteye.com/blog/1211632"
---

场景 监听者接口 事件类型       你想知道一个WEB应用是否**添加**，**删除**或**替换**了一个**上下文属性** Javax.servlet.ServletContextAttributeListener  
attributeAdded  
attributeRemoved  
attributeReplaced ServletContextAttributeEvent 你想知道什么时候**添加**，**删除**或者**替换**一个**请求属性** Javax.servlet.ServletRequestAttributeListener  
attributeAdded  
attributeRemoved  
attributeReplaced ServletRequestEvent 你想知道什么时候**添加**，**删除**或者**替换**一个**会话属性** javax.servlet.http.HttpSessionAttributeListener  
attributeAdded  
attributeRemoved  
attributeReplaced HttpSessionBindingEvent       每次**请求**到来你都想知道，以便建立日志记录或者干点初始化之类的事情 Javax.servlet.ServletRequestListener  
requestInitialized  
requeseDestoryed ServletRequestEvent 你想知道有多少个并发用户，也就是说，你想跟踪活动**会话** javax.servlet.http.HttpSessionListener  
sessionCreated  
sessionDestoryed  
HttpSessionEvent 你想知道是否创建或者撤销了一个**上下文** javax.servlet.ServletContextListener  
contextInitialized  
contextDestoryed ServletContextEvent       你有一个属性类（这个属性类的对象将被放在一个属性中），而且你希望这个类型的对象绑定到一个会话或从一个会话删除时得到通知 javax.servlet.http.HttpSessionBindingListener  
valueBound  
valueUnbound HttpSessionBindingEvent 你有一个属性类，而且你喜欢子属性对象绑定的会话迁移到另一个JVM时得到通知 javax.servlet.http.HttpSessionActivationListener  
sessionDidActivate  
sessionWillPassivate HttpSessionEvent