创建一个类,实现HttpSessionBindingListener,然后在
public void valueUnbound(HttpSessionBindingEvent event) {
// 在此方法里做用户退出时的处理
}把此类实例化,然后放在用户的session里。用户退出时会调用valueUnbound
public void valueUnbound(HttpSessionBindingEvent event) {
// 在此方法里做用户退出时的处理
}把此类实例化,然后放在用户的session里。用户退出时会调用valueUnbound
解决方案 »
- JSP中如何实现返回同一页面的顶部
- jsp页面中的问题
- 遇到一个奇怪的问题,高手进来看看,高分!
- struts登陸的問題
- 寻求高手解决一个关于JSP生成html的问题.......
- java.lang.String cannot be cast to
- JSP中文问题。
- 请问高手,Jbuilder4中为何不能支持javaScript脚本?如何解决?
- lhgdialog按钮回调方法
- 怎么去掉浏览器访问服务器时,开发者工具显示的响应头信息?
- 谁能给我一个使用jsp标签的例子!跟贴有分!!!
- 我使用jbuilder做的软件系统包括servlet,jsp,applet,打成了war包,可是却始终不能运行applet。
import javax.servlet.http.*;/**
* Database implementation of the Authorization interface.
*/
public final class Authorization implements Serializable, HttpSessionBindingListener { private static final long serialVersionUID = 01L; private int userID; /**
* Constucts a new DbAuthorization with the specified userID.
*
* @param userID the userID to create an authorization token with.
*/
protected Authorization(int userID) {
this.userID = userID;
} //FROM THE AUTHORIZATION INTERFACE// public int getUserID() {
return userID;
} public boolean isAnonymous() {
return userID == -1;
} /*static int loginUserCount = 0; public static int getLoginUserCount() {
return loginUserCount;
}
*/
public void valueBound(HttpSessionBindingEvent event) {
// loginUserCount++;
} public void valueUnbound(HttpSessionBindingEvent event) {
// loginUserCount--;
UserLoginManage.remove(userID);
//System.out.println("userID:"+userID);
LogManage.addLog(new Log(userID,UserManage.getUser(userID).getUnitID(),"",null,
"login.jsp?logout=true","离开","UserLogin",0,"","session过期,自动离开",0));
}
}