public class MyListener implements HttpSessionAttributeListener { public void attributeAdded(HttpSessionBindingEvent se) { if ("user".equals(se.getName())) { UserAction.count++; User user = (User) se.getValue(); System.out.println(user.getName() + " has login"); UserAction.onLineUser.add(user.getName()); System.out.println(UserAction.onLineUser.size()); } }
public void attributeRemoved(HttpSessionBindingEvent se) { // TODO Auto-generated method stub if ("user".equals(se.getName())) { User user = (User) se.getValue(); System.out.println(user.getName() + " has logout"); UserAction.onLineUser.remove(user.getName()); System.out.println(UserAction.onLineUser.size()); UserAction.count--; } }
public void attributeReplaced(HttpSessionBindingEvent se) { // TODO Auto-generated method stub