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 restrictions are placed on the values of each case of a switch statement?
AS a developer will u create a data source in connection pool? If so how will u do that, how to access the object from connection pool using IRAD tool?
What are the different approaches to represent an inheritance hierarchy?
How to determine SGA site?
why static class in java
What are various types of class loaders used by jvm?
What is the difference between static and non-static with examples?
Are we allowed to change the transaction isolation property in middle of a transaction?
What is prototype?
Why is string immutable in java?
What is colon_pkg_prefixes and what is its use?
Why do I get a duplicate name error when loading a jar file?
Can I use javascript to submit a form?
Can you give me a simple example of using the requiredif validator rule?
What is the purpose of the notify() method?