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

public class onlinelisten implements HttpSessionListener,
        HttpSessionAttributeListener {
    public static int online = 0;
    public void attributeAdded(HttpSessionBindingEvent arg0) {
        System.out.println("增加了属性");

    }

    public void attributeRemoved(HttpSessionBindingEvent arg0) {
        System.out.println("移除");

    }

    public void attributeReplaced(HttpSessionBindingEvent arg0) {
        System.out.println("替换");

    }

    public void sessionCreated(HttpSessionEvent se) {
        System.out.println("创建");
        online = online +1;
    }

    public void sessionDestroyed(HttpSessionEvent se) {
        System.out.println("销毁");
    }

}
View Code