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
how to make a index.jsp for running the site in internet and find an error for connection with weblogic server and java that give an error invalid object name.and how to maintain session.
What are the design considerations while making a choice between using interface and abstract class?
What is the difference between ear, jar and war file?
How to implement RMI in Java?
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!
What are the different class loaders used by jvm?
why static class in java
What is the difference between long.class and long.type?
Why use a datasource when you can directly specify a connection details? (in a J2EE application)
What is a class loader?
What is local interface. How values will be passed?
Will the general public have access to the infobus apis?
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?
What is Remote Server?
what are getters and setters in Java with examples?