session监听

package com.listener;

import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;

/**
* 对session的监听
*/
public class HttpSessionListenerDemo implements HttpSessionListener {

public void sessionCreated(HttpSessionEvent event) {
// 创建session时触发
System.out.println("** SESSION 创建,SESSION ID = " + event.getSession().getId());
}

public void sessionDestroyed(HttpSessionEvent event) {
// 销毁session时触发
System.out.println("** SESSION 销毁,SESSION ID = " + event.getSession().getId());
}

}

 

web.xml

<listener>
<listener-class>com.listener.HttpSessionListenerDemo</listener-class>
</listener>

posted @ 2013-04-16 11:07  幻星宇  阅读(206)  评论(0编辑  收藏  举报