Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Count number of users accesing the web application

 
yekkala krishna
Ranch Hand
Posts: 105
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

You can write a session listener for your application.

The code looks like this.

 
yekkala krishna
Ranch Hand
Posts: 105
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 .

 
Virendrasinh Gohil
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 862
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Emir Qureshi
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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) ?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic