最近写了一个HttpSessionListener,有人访问时,能自动调用sessionCreated,
可是session过期时,sessionDestroyed不被调用,为什么呢?!我用的是TOMCAT4
可是session过期时,sessionDestroyed不被调用,为什么呢?!我用的是TOMCAT4
解决方案 »
- Eclipse中Debug时使用的工具条,(包含F5,F6等等)出不来了,怎么给调出来?
- jsp聊天室带管理员功能
- 急求一份用jsp+JAVASCRIPT实现树型菜单的代码
- JSP中iterator的问题
- struts配置问题--有些莫名奇妙
- 怎么让JSP页面里弹出的Frame (java.awt.Frame)窗口出现在最前端?
- 请问如何使用jar命令,在线
- javaweb基础问题,编译和调试
- Spring cloud eureka 怎么消费服务调用接口?
- spring suite tool安装成功,eclipse properties没有spring选项
- 请教高手JSP客户端如何加密,
- struts 里面 FormFile上传文件的问题
import javax.servlet.http.HttpSessionListener;public class OnlineListener implements HttpSessionListener {
private int count=0;
public void sessionCreated(HttpSessionEvent se) {
// TODO Auto-generated method stub
count++;
se.getSession().getServletContext().setAttribute("onlineCount",new Integer(count));
System.out.println("add");
} public void sessionDestroyed(HttpSessionEvent se) {
// TODO Auto-generated method stub
count--;
String name = (String)se.getSession().getAttribute("name");
se.getSession().removeAttribute("name");
System.out.println(name);
Vector v = (Vector)se.getSession().getServletContext().getAttribute("namelist");
for(int i=0;i<v.size();i++)
{
String n = (String)v.elementAt(i);
if(name.equals(n))
{
v.remove(i);
}
}
se.getSession().getServletContext().setAttribute("onlineCount",new Integer(count));
System.out.println("remove"+" "+name);
}
}
2。看一下session过期时间是否设置了
3。最好能debug看一下session创建和过期时listener是否正常执行了~