Anton Hinxman
|
Posted: 12/08/2004, 2:05 AM |
|
Put in a listener class and monitor the CCS attributes being created in the session. It is quite enlightening although verbose.
I have a class which monitors and maintains the login status of users and then updates my user table with such status. It forms a licence restriction function as well - if required.
Perhaps your TomCat session timeout is way too small?
public final class UserLoginListener extends java.util.Date
implements
HttpSessionAttributeListener,
HttpSessionListener,
HttpSessionBindingListener,
ServletContextListener,
ServletContextAttributeListener {
You will need to monitor:
public void valueBound(HttpSessionBindingEvent event) {
try {
com.codecharge.util.CCLogger.getInstance().debug("Attribute "+ event.getName()+ " has been created"+
", value ="+ event.getValue());
} catch (Exception ex){
com.codecharge.util.CCLogger.getInstance().error(".valueBound has error:"+ ex.getMessage());
ex.printStackTrace();
}
}
public void valueUnbound(HttpSessionBindingEvent event) {
try {
com.codecharge.util.CCLogger.getInstance().debug("Attribute "+ event.getName()+ " has been removed"+
", value ="+ event.getValue());
if("UserLogin".equals(event.getName())) {
// event.getValue()
reset(""+event.getValue());
com.codecharge.util.CCLogger.getInstance().debug("Unbinding: "+ event.getValue());
}
} catch (Exception ex){
com.codecharge.util.CCLogger.getInstance().error(".valueUnbound has error:"+ ex.getMessage());
ex.printStackTrace();
}
}
public void attributeAdded(HttpSessionBindingEvent event) {
try {
// We look for...
// "UserID" String Log Name
// "UserLogin" String login name
// "GroupID" numeric as string?
// Ignore the following (repeatedly recreated)
if("YOURDBCONNAMEDateFormat".equals(event.getName()) || "YOURDBCONNAMEBooleanFormat".equals(event.getName()) ) {
return;
}
com.codecharge.util.CCLogger.getInstance().debug("Attribute "+ event.getName()+ " has been added " +
"in HttpSession HttpSession ="+ event.getSession()+
", value ="+ event.getValue());
if("UserLogin".equals(event.getName())) {
etc.
Plumbed into Tomcat application via:
<!-- Define application events listeners -->
<listener>
<listener-class>
UserLoginListener
</listener-class>
</listener>
You can then see what is going on.
Regards
Anton
|