servlet中的8个监听者

场景:

你想知道一个web应用上下文中是否增加、删除或替换了一个属性

监听者接口:

javax.servlet.ServletContextAttributeListener

    attributeAdded

    attributeRemoved

    attributeReplaced

事件类型:ServletContextAttributeEvent


场景:

你想知道有多少个并发用户,也就是说,你想跟踪活动的会话

监听者接口:

javax.servlet.http.HttpSessionListener

    sessionCreated

    sessionDestroyed

事件类型:HttpSessionEvent


场景:

每次请求到来时你都想知道,以便建立日志记录

监听者接口:

javax.servlet.ServletRequestListener

    requestInitialized

    requestDestroyed

事件类型:ServletRequestEvent


场景:

增加、删除或替换一个请求属性时你希望能够知道

监听者接口:

javax.servlet.ServletRequestAttributeListener

    attributeAdded

    attributeRemoved

    attributeReplaced

事件类型:ServletRequestAttributeListener


场景:

你有一个属性类,而且你希望这个类型的对象在绑定到一个会话或从会话中或从会话删除时得到通知

监听者接口:

javax.servlet.HttpSessoinBindingListener

    valueBound

    valueUnbound

事件类型:HttpSessionBindingEvent


场景:

增加、删除或添加一个会话属性时你希望能够知道

监听者接口:

javax.servlet.HttpSessionAttributeListener

    attributeAdded

    attributeRemoved

    attributeReplaced

事件类型:HttpSessionBindingEvent


场景:

你想知道是否创建或撤销了一个上下文

监听者接口:

javax.servlet.ServletContextListener

    contextInitializated

    contextDestroyed

事件类型:ServletContextEvent


场景:

你有一个属性类,而且希望这个类型的对象在其绑定的会话迁移到另一个JVM时得到通知

监听者接口:

javax.servlet.http.HttpSessionActivationListener

    sessionDidActivite

    sessionWillPassivate

事件类型:HttpSessionEvent


注意:

HttpSessionListener和HttpSessionActivationListener共用HttpSessionEvent事件

ServletSessionBindingListener和ServletSessionAttributeListener共用HttpSessionBindingEvent事件

转载于:https://www.cnblogs.com/rowsy/archive/2012/11/08/2838817.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值