Stephen Charles Huey
2004-07-15 23:06:29 UTC
My session listener doesn't seem to be listening. At the top of my
web.xml (before any servlet elements, and I have nothing like a filter
or anything else before it), I have this:
<listener>
<listener-class>central.OurSessionListener</listener-class>
</listener>
Here is my listener class:
package central;
import java.util.HashMap;
import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;
import wwxchange.utility.*;
import wwxchange.beans.*;
public class OurSessionListener implements HttpSessionListener {
public void sessionCreated(HttpSessionEvent se) {
HttpSession session = se.getSession();
UserAcctBean user = (UserAcctBean)
session.getAttribute("currentuser");
String loginID = user.getLoginID();
System.out.println("Added session: " + session.getId() + " for user
" + user.getLoginID());
SystemControl.addActiveUser(session.getId(), user.getLoginID() );
}
public void sessionDestroyed(HttpSessionEvent se) {
HttpSession session = se.getSession();
SystemControl.removeActiveUser(session.getId());
System.out.println("Removed session: " + session.getId());
}
}
My SystemControl's static HashMap doesn't seem to be getting updated,
and the above methods aren't even getting called because nothing is
going to stdout when I log in as different users.
What am I doing wrong? Is my listener not registered to listen?
Thanks,
Stephen
web.xml (before any servlet elements, and I have nothing like a filter
or anything else before it), I have this:
<listener>
<listener-class>central.OurSessionListener</listener-class>
</listener>
Here is my listener class:
package central;
import java.util.HashMap;
import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;
import wwxchange.utility.*;
import wwxchange.beans.*;
public class OurSessionListener implements HttpSessionListener {
public void sessionCreated(HttpSessionEvent se) {
HttpSession session = se.getSession();
UserAcctBean user = (UserAcctBean)
session.getAttribute("currentuser");
String loginID = user.getLoginID();
System.out.println("Added session: " + session.getId() + " for user
" + user.getLoginID());
SystemControl.addActiveUser(session.getId(), user.getLoginID() );
}
public void sessionDestroyed(HttpSessionEvent se) {
HttpSession session = se.getSession();
SystemControl.removeActiveUser(session.getId());
System.out.println("Removed session: " + session.getId());
}
}
My SystemControl's static HashMap doesn't seem to be getting updated,
and the above methods aren't even getting called because nothing is
going to stdout when I log in as different users.
What am I doing wrong? Is my listener not registered to listen?
Thanks,
Stephen