This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Hello All, I want to know that how many users currently communicating with my web-application .Is there any way to find out Using JavaServlet Api may be using ServletContext . I appreciate any help . Saima.
In a servlet 2.3 environment (Tomcat 4), you can accomplish your goal without getting into the innards of the container. Simple create and register an HttpSessionListener, which will be notified every time a session within your app is created or destroyed -- it's easy to maintain a local HashMap (or something) of the currently active sessions. Craig
Does anyone know if there's a way to get some kind of a reference to all of the active sessions in a webapp? I just want to know how many Sessions there are. I'd just like to be able to say something like "There are currently X Number of users online" on some page. -Cavan Morris
Joined: Jan 15, 2002
Hello Carig, Thanks for your reply ,but actually you repeated my question .As I was also asking about the no of users currently online to communicate simultaneously with any web-aps. This is interesting thing and there must be some solution . Thanks anyway .
Well Khan , What u need to do is this .. 1) u need to declare a Haspmapor a Hashtable in the class. This u must me doing(i hope) to keep track, that the user doesnt log on two from two machine simaltaneously , any how even if u havent ,no problem . 2) everytime a user logs on to the ur web application u have to check whether his login name is already there or not . if it is not there u put his name in the map . 3) every time a person logs out, u remove his name from the hashmap 4) now to find out what exactly ur requirement is what u can do is , u can call size() of the hashmap or table .which will return u the count of number of people who are using your application
Try and Try Till u succeed<br /> <br />Sandeep Jain
Joined: Jan 15, 2002
Thanks a lot Sandeep. I think now i will solve this if I need anything else further i will let you know . Thanks again.