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


Please Help Members By Posting Answers For Below Questions

What does module-relative mean?

568


What are the different algorithms used for clustering?

541


What is jboss?

565


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?

575


Describe, in general, how java's garbage collector works?

530






what are the activation groupworks?

1667


In inglish: How to convert jar to exe files? Em português: Como converter arquivos .jar para .exe?

2147


What are the diff types of exception?

547


What is the argument type of a programs main() method?

556


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!

1357


Java is fully object oriented languages or not?

530


Can I import same package/class twice? Will the jvm load the package twice at runtime?

637


Which component handles cluster communication in jboss?

616


Explain about local interfaces.

574


Define aop(assepct oriented programing)?

624