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 does module-relative mean?
What are the different algorithms used for clustering?
What is jboss?
In our urls and in the text of the buttons we have comma. Its causing an error. Is there a way to change the delimiting character for the menu arguments?
Describe, in general, how java's garbage collector works?
what are the activation groupworks?
In inglish: How to convert jar to exe files? Em português: Como converter arquivos .jar para .exe?
What are the diff types of exception?
What is the argument type of a programs main() method?
int x=5,i=1,y=0; while(i<=5) { y=x++ + ++x; i=i+2; } System.out.println(x); System.out.println(y); System.out.println(i); How to solve this? Please explain!
Java is fully object oriented languages or not?
Can I import same package/class twice? Will the jvm load the package twice at runtime?
Which component handles cluster communication in jboss?
Explain about local interfaces.
Define aop(assepct oriented programing)?