HttpSessionListener实现统计在线人数
来源:互联网 发布:java 所有数据类型 编辑:程序博客网 时间:2024/05/16 14:37
HttpSessionListener主类:
package com.httpSessionListener;import javax.servlet.http.HttpSessionEvent;import javax.servlet.http.HttpSessionListener;public class OnlineNum implements HttpSessionListener{ //静态变量累计count,这个过程中每一个用户将new一个OnlineNum实例出来private static int count;public static int getCount() {return count;} //session创建时将创建对象并调用此方法public void sessionCreated(HttpSessionEvent arg0) {// TODO Auto-generated method stubSystem.out.println("增加了");count++;} //浏览器关闭或手动关闭session时将调用该方法public void sessionDestroyed(HttpSessionEvent arg0) {// TODO Auto-generated method stubcount--;}}
2,创建session的类
public void doGet(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException {request.getSession().setAttribute("user", "user");System.out.println(request.getSession().getAttribute("user"));request.getRequestDispatcher("index.jsp").forward(request, response);//response.sendRedirect(request.getContextPath()+"/index.jsp");}
- HttpSessionListener实现统计在线人数
- HttpSessionListener统计在线人数
- HttpSessionListener统计在线人数
- HttpSessionListener统计在线人数
- HttpSessionListener统计在线人数
- HttpSessionListener统计在线人数
- HttpSessionListener统计在线人数
- httpSessionListener统计在线人数
- HttpSessionListener统计在线人数
- HttpSessionListener统计在线人数
- [java]HttpSessionListener实现统计在线人数
- HttpSessionListener实现网站在线人数统计
- HttpSessionListener实现网站统计在线人数
- [java]HttpSessionListener实现统计在线人数
- HttpSessionListener统计在线人数 [转]
- 利用HttpSessionListener统计在线人数
- 利用HttpSessionListener统计在线人数
- 利用HttpSessionListener统计在线人数
- OpenCV学习:Mat类详细解析+源码剖析(二)构造函数
- 【Struts2+Spring3+Hibernate3】SSH框架整合实现CRUD_1.1
- 最大值最小化
- 多段图的最短路径问题-----动态规划法
- Android开发(12)--多线程处理机制之Handler的使用方法
- HttpSessionListener实现统计在线人数
- “十天一本书”之十——《处好人际关系小窍门》随感
- 使用myeclipse导入JSP及Struts2项目和删除项目注意事项
- .bat文件中for的用法
- Findbug编写新的规则
- 架构师不可不知的十大可扩展架构
- android mediaplayer 1
- listView当选中上下滑动的时候背景是白色的
- 数据库表的设计原则