ok, Harpartap, as you can see, I've changed my name. I hope this is good.
I'm using
Tomcat 4.0 and in web.xml file I'm using this lines:
<web-app>
<listener>
<listener-class>
SessionCounter
</listener-class>
</listener>
</web-app>
And this is my listener class:
// ...imports...
public class SessionCounter implements HttpSessionListener, Serializable {
private static int TotalSessions = 0;
private static int ActiveSessions = 0;
public void sessionCreated(HttpSessionEvent event) {
HttpSession session = event.getSession();
TotalSessions++;
ActiveSessions++;
session.setMaxInactiveInterval(60);
// I've prove session.setMaxInactiveInterval(1); too
registerCounter(event);
}
public void sessionDestroyed(HttpSessionEvent event) {
HttpSession session = event.getSession();
ActiveSessions--;
System.out.println("Session destroyed..." + session.getId());
}
public static int getTotalSessions() {
return(totalSessions);
}
public static int getActiveSessions() {
return(ActiveSessions);
}
private synchronized void registerCounter(HttpSessionEvent event) {
HttpSession session = event.getSession();
session.setAttribute("SessionCounter", this);
}
}
I think it's correct, isn't it?
When I must to send to my users toward the login page??
Thanks.