Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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 is handle?

2330


What is a sessionfactory? Is it a thread-safe object?

1181


Why are some of the class and element names counter-intuitive?

1086


What is the difference between a menuitem and a checkboxmenuitem?

1053


Do I have to use jsps with my application?

997


What event results from the clicking of a button?

1192


What is RMI and what are the services in RMI?

1101


How to pass parameters in RMI?

2232


Which characters may be used as the second character of an identifier, but not as the first character of an identifier?

1014


What does module-relative mean?

1099


what are the advantages of JTA over JTS?

2161


What’s jboss jbpm?

984


What value does read() return when it has reached the end of a file?

1001


What is the diffrence between a local-tx-datasource and a xa-datasource?

1013


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?

2070