1. 程式人生 > >HttpSessionListener的用法和例項

HttpSessionListener的用法和例項

3)HttpSessionListener:

Session建立和銷燬的時候可以監聽到。

例 2.2.3.1

package com;
import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;
public class MyHttpSessionListener implements
HttpSessionListener {
    public void sessionCreated(javax.servlet.http.HttpSessionEvent arg0) {
        System.out.println("馬克-to-win session Initialized"+arg0.getSession().getId());
    }
    public void sessionDestroyed(javax.servlet.http.HttpSessionEvent arg0) {
        System.out.println("馬克-to-win destroyed"+arg0.getSession().getId());
    }

詳情請見:http://www.mark-to-win.com/index.html?content=Jsp/jspUrl.html&chapter=Jsp/jsp6_web.html#HttpSessionListener