I wantr to know, How many number of users logged in to
website? can any one answer
Answer Posted / sunil
HttpSessionListener is Listener whenever session is created.
import javax.servlet.http.HttpSessionListener;
import javax.servlet.http.HttpSessionEvent;
public class SessionCounter implements HttpSessionListener {
private static int activeSessions = 0;
public void sessionCreated(HttpSessionEvent se) {
activeSessions++;
}
public void sessionDestroyed(HttpSessionEvent se) {
if(activeSessions > 0)
activeSessions--;
}
public static int getActiveSessions() {
return activeSessions;
}
}
| Is This Answer Correct ? | 15 Yes | 0 No |
Post New Answer View All Answers
what is handle?
What is a sessionfactory? Is it a thread-safe object?
Why are some of the class and element names counter-intuitive?
What is the difference between a menuitem and a checkboxmenuitem?
Do I have to use jsps with my application?
What event results from the clicking of a button?
What is RMI and what are the services in RMI?
How to pass parameters in RMI?
Which characters may be used as the second character of an identifier, but not as the first character of an identifier?
What does module-relative mean?
what are the advantages of JTA over JTS?
What’s jboss jbpm?
What value does read() return when it has reached the end of a file?
What is the diffrence between a local-tx-datasource and a xa-datasource?
In RMI, inorder to sent the stub reference to the client, is we have to load the server object first into the memory or can we directly sent reference to the client?