Serverlet监听器
来源:互联网 发布:windows java进程监控 编辑:程序博客网 时间:2024/06/08 02:45
Servlet监听器用处
可以集中处理特定的事件
HttpSession监听器接口
HttpSessionAttributeListener
HttpSessionBindingListener
HttpSessionActivationListener
除了BindingListener以外,其它三个都要在web.xml中声明
HttpSessionListener 监听session的销毁和创建,方法有
sessionCreated()
sessionDestroyed()
HttpSessionAttributeListener 监听Session属性的改变
attributeAdded()
attributeReplaced()
attributeRemoved()
产生事件的代码:
session.setAttribute("username","SunWukong");
session.setAttribute("username","ZhangFei");
session.removeAttribute("username");
HttpSessionBindingListener
valueBound()
valueUnbound()
调用机制:
如果一个类实现了HttpSessionBindingListener接口,则当这个类的对象通过session.setAttribute()被
绑定到Session对象中时,则该对象的valueBound()方法被自动调用,当这个对象从Session中删除时(调用session.invalidate()和session.removeAttribute()方法,或Session对象过期)valueUnbound()方法将被自动调用。
HttpSessionActivationListener
sessionDidActivate()
sessionWillPassivate()
调用机制:
活化(Activate)与(钝化)Passivate是Web容器为了更好的利用系统资源或者进行服务器负载平衡等原因而对特定对象采取的措施。
会话对象的钝化指的是暂时将会话对象通过对象序列化的方式储存到硬盘上,而会话对象活化与钝化相反,Web容器把硬盘上储存的会话对象文件重新加载到Web容器中。
sessionDidActivate()与sessionWillPassivate()方法分别于会话对象活化后和会话对象钝化前由容器进行自动调用。
ServletContext监听器接口
contextInitialized()
contextDestroyed()
ServletContextAttributeListener
attributeAdded()
attributeReplaced()
attributeRemoved()
HttpServletRequest监听器
requestInitialized()
requestDestroyed()
ServletRequestAttributeListener
attributeAdded()
attributeReplaced()
attributeRemoved()
- Serverlet监听器
- serverlet
- Serverlet详解
- 关于serverlet
- Serverlet详解
- serverlet学习
- Serverlet 介绍
- serverlet总结
- serverlet 多线程
- Serverlet生命周期
- Serverlet简介
- Serverlet简介
- Serverlet详解
- serverlet总结
- 初步集成serverlet
- 别人的SERVERLET笔记
- 忘记了的serverlet
- jsp/serverlet redirct
- JSP EL
- JSP Tag
- Elasticsearch搜索引擎
- python 贪心算法实现 斗地主发牌
- 数据库删除重复属性列,错误[HY000][1093] You can't specify target table 'orders' for update in FROM clause
- Serverlet监听器
- [LintCode]102.带环链表
- nyoj 571 整数划分(三)(递归)
- Servlet过滤器
- 简单排序算法总结(C语言版)
- reduceByKeyAndWindow实现基于滑动窗口的热点搜索词实时统计(Java版本)
- JSP 分页
- Gson 的使用和GsonFormat插件的使用
- 百度/谷歌 高级搜索指令