Getting No: and User Detals of Active Users
I have one web application and i want to get the number of users who are currently accessing the application.
Also I want to get the user details of each user, which is stored in a database.
How can I do this? Pls help.
Your web host may have a free setup for that, like a html snippet that you insert
into your web page, at least mine (start.no) has.
If that is not an option you will have to have a cgi-script/servlet/php on the server
that your web app can access for counting.
But i am using Java/JSP/MySQL
Easiest way would be to have a table in your database which records all user activity. Each time a user accesses a page, update the date field. then, when you want to count the active users, just count the number of records with a date within the last 5 minutes.
Yes. Now i am doing it using table.
But i need some better way of doing it.
You could try a class with a static attribute.
but then it would be fairly difficult to account for people not being active for a certain period of time. If you manage to incorporate that, it should work.
But still v need to have table, right? or is it any other method? If so cud you pls explain in detail?
As I recall, a servlet is not loaded each time a client accesses it, the servlet stays
memory resident after first invokation so a static variable will be "user global", and
also reset when the server is restarted.
One partial solution could be cookies, but not all clients accept them. I would go for
a very simple table solution: add all traffic to the table, and on certain intervals do
a "cleanup" eliminating multiple accesses made by the same user(s). This action could
be controlled by a class variable that would spawn a cleanup-process on the server
at, say, every 500 access made.
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center