tw.com.javaworld.CH10.UserTrace (Java2HTML)

| UserTrace.java |

    1 package tw.com.javaworld.CH10;
    2
    3 import java.util.*;
    4 import javax.servlet.http.*;
    5 import tw.com.javaworld.CH10.UserList;
    6
    7 public class UserTrace implements javax.servlet.http.HttpSessionBindingListener {
    8
    9     private String user_name;
    10    private UserList container = UserList.getInstance();
    11
    12    public String getUserName() {
    13        return user_name;
    14    }
    15
    16    public void setUserName(String name) {
    17        user_name = name;
    18    }
    19
    20    // 當UserTrace被加入session物件時會呼叫此方法
    21    public void valueBound(HttpSessionBindingEvent event) {
    22    }
    23
    24    // 當UserTrace被移出session物件時會呼叫此方法
    25    public void valueUnbound(HttpSessionBindingEvent event) {
    26        container.removeUser(user_name);
    27    }
    28}
    29