Bắt sự kiện session timeout

Bắt sự kiện session timeout

Đây là vấn đề của khá nhiều bạn, và cách giải quyết sau đây của tôi hi vọng sẽ giúp được bạn.
Dùng SessionListener
1.Tạo một sessionListener như sau:
public class SessionListener implements HttpSessionListener {

/** Creates a new instance of SessionListener */
public SessionListener() {
}

public void sessionCreated(HttpSessionEvent se) {
HttpSession session = se.getSession();
System.out.println("Created. Session id"+ session.getId());
}

public void sessionDestroyed(HttpSessionEvent se) {
HttpSession session = se.getSession();
System.out.println("Destroyed. Session id"+ session.getId());
// do you stuff here
}
}

2.Và ta sẽ khai báo Listener:
<listener>
<listener-class>com.bds.psolution.SessionListener</listener-class>
</listener>

Cao Trong Hien

1 Response to "Bắt sự kiện session timeout"

Nặc danh said :
lúc 20:31 12 tháng 11, 2009
Nhận xét này đã bị quản trị viên blog xóa.

Đăng nhận xét