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
Explain about RMI Architecture?
What event results from the clicking of a button?
Why is string immutable in java?
What is table mutation and how do you avoid it?
What is the infobus?
What do you know about seam?
what is the use of State Factories?
What restrictions are placed on the location of a package statement within a source code file?
How to deploy Jar, War files in J2EE?
what is meant by JRMP?
Why are some of the class and element names counter-intuitive?
What is the immediate superclass of the applet class?
what is handle?
What value does read() return when it has reached the end of a file?
What is aop(assepct oriented programing)?