📄 sessionlistener.java
字号:
/*
* SessionListener.java
*
* Created on 2007年4月28日, 下午1:46
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package com.ebuy.web.listeners;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpSessionEvent;
/**
*
* @author Administrator
*/
public class SessionListener implements javax.servlet.http.HttpSessionListener
{
/** Creates a new instance of SessionListener */
public SessionListener()
{
}
public void sessionCreated(HttpSessionEvent se)
{
HttpSession session=se.getSession();
ServletContext context=session.getServletContext();
int total=Integer.parseInt(context.getAttribute("total").toString());
total ++;
context.setAttribute("total",total);
session.setAttribute("index",total);
int online=Integer.parseInt(context.getAttribute("online").toString());
online++;
context.setAttribute("online",online);
}
public void sessionDestroyed(HttpSessionEvent se)
{
ServletContext context=se.getSession().getServletContext();
int online=Integer.parseInt(context.getAttribute("online").toString());
online--;
context.setAttribute("online",online);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -