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
To identify IDL language what mapping mechanism is used?
Which textcomponent method is used to set a textcomponent to the read-only state?
Do we need to override service() method
How is a java object message delivered to a non-java client?
Define the remote object implementation?
What is the difference between RMI and Corba?
What is difference between object state and behavior?
When is the best time to validate input?
What are callback interfaces?
What state does a thread enter when it terminates its processing?
Is the ternary operator written x : y ? Z or x ? Y : z ?
When a thread blocks on i/o?
Name the eight primitive java types.
What is a class loader? What are the different class loaders used by jvm?
What is the RMI and Socket?