File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes Count number of users accesing the web application Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Count number of users accesing the web application" Watch "Count number of users accesing the web application" New topic
Author

Count number of users accesing the web application

yekkala krishna
Ranch Hand

Joined: Mar 04, 2007
Posts: 105
Hi,

In our web application we are using servlets,jsp and spring technologies.Here we are also maintaining session mechanism in our application.But now i need to count number of users accessing our web application at a time. How can i implement this mechanism if anybody having idea please suggest me.

Regards,
Rama Krishna.Y
Sriram Ture
Greenhorn

Joined: Aug 20, 2010
Posts: 23
Hi,

You can write a session listener for your application.

The code looks like this.

yekkala krishna
Ranch Hand

Joined: Mar 04, 2007
Posts: 105
Hi Sriram,

Thanks for your suggestion.
Now i am able to count number of active and inactive sessions.

regards,
Rama Krishna.Y
Ravi Kiran Va
Ranch Hand

Joined: Apr 18, 2009
Posts: 2234

Are you not handling Guest users ??

Your coding is as such that :

If a User opens a Web page you cant create a Session for him , until he logs into the web site .(He may open the web page just to browse , without logging in )

I think you have got the point i am mentioned .


Save India From Corruption - Anna Hazare.
Virendrasinh Gohil
Ranch Hand

Joined: Jun 09, 2004
Posts: 46
Ravi Kiran V wrote:Are you not handling Guest users ??
Your coding is as such that :
If a User opens a Web page you cant create a Session for him , until he logs into the web site .(He may open the web page just to browse , without logging in )

I think that depends on the business scenario whether Yekkala Krishna wants to know number of concurrent users or number of concurrent active request? If it's active users, sriram's reply is sufficient but if it's number of active request, you may choose ServletRequestListener instead.

One more modification, I would prefer to use AtomicInteger instead.
steve souza
Ranch Hand

Joined: Jun 26, 2002
Posts: 860
JAMon is an api that counts things and lets you display them on a web page. For example you can count and time web page accesses, sql calls and more without changing your code. Here is an example of how you can track sessions.

http://jamonapi.sourceforge.net/httpsession_sample.html


http://www.jamonapi.com/ - a fast, free open source performance tuning api.
JavaRanch Performance FAQ
Emir Qureshi
Greenhorn

Joined: Mar 29, 2011
Posts: 12
Virendrasinh Gohil wrote:
Ravi Kiran V wrote:Are you not handling Guest users ??
Your coding is as such that :
If a User opens a Web page you cant create a Session for him , until he logs into the web site .(He may open the web page just to browse , without logging in )

I think that depends on the business scenario whether Yekkala Krishna wants to know number of concurrent users or number of concurrent active request? If it's active users, sriram's reply is sufficient but if it's number of active request, you may choose ServletRequestListener instead.

One more modification, I would prefer to use AtomicInteger instead.


ServletRequestListener will only give the total count of request in web application scope. However, that count will be more than the number of users(Guest + Member) as each user may have more than one request.

How to find out the total count of users (Guest + Member) ?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Count number of users accesing the web application
 
Similar Threads
Number of users
SCEA Part1 EPractize Labs - some answer seems incorrect
How number of active Sessions count in Clustered server environment WAS7?
WebLogic 6.1 SP3 - Stateful Session Bean Problem
candidate for map reduce