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 restrictions are placed on the values of each case of a switch statement?

960


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?

2096


What are the different approaches to represent an inheritance hierarchy?

1021


How to determine SGA site?

2478


why static class in java

1724


What are various types of class loaders used by jvm?

934


What is the difference between static and non-static with examples?

1869


Are we allowed to change the transaction isolation property in middle of a transaction?

989


What is prototype?

1070


Why is string immutable in java?

1058


What is colon_pkg_prefixes and what is its use?

2464


Why do I get a duplicate name error when loading a jar file?

1081


Can I use javascript to submit a form?

1101


Can you give me a simple example of using the requiredif validator rule?

1069


What is the purpose of the notify() method?

1020