如何统计在线人数,急!!!
要在jsp里实时统计并显示在线人数,
1、想用HttpSessionListener来做,但web服务器只支持servlet2.2,不能用。
2、想调用ServletContext的getServlets()方法,但该方法() 已经Deprecated. As of Java Servlet API 2.0, with no replacement.This method will be permanently removed in a future version of the Java Servlet API.那么将来升级jdk后会失效。
3、想在用户登陆时在application(ServletContext)里使某个attribute加1,然后用户注销登陆时减1,但如果用户直接关闭ie,或者用户断线,或其它情况(如用户直接点击重登陆链接),处理起来又太繁琐甚至无法实现。
希望能以类似1、2、的方式来解决问题,或者是否有更好的方法,大家帮忙,多谢!