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 Getting online users list Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Getting online users list" Watch "Getting online users list" New topic
Author

Getting online users list

Subhash Yadav
Greenhorn

Joined: Feb 09, 2013
Posts: 5
Hello,
I am creating a chat application where in I need to create a list of online users. So I have used ServletContext and added a map to it using context.setAttribute() method. this map takes 2 arguments, session.getId() and username (through database). Since I have added this map to ServletContext , it is available to all sessions (please correct me if i am wrong). the overall idea is, when a user log-in he is authenticated and his name and session id is passed as argument to the map and the map is made available to the jsp page (using context.getAttribute). However when I implement this it returns the username and session id of it's only and not of other users who are logged in earlier.
thanks
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12682
    
    5
So I have used ServletContext and added a map to it using context.setAttribute() method. this map takes 2 arguments, session.getId() and username (through database).


Are you perhaps creating a new map every time instead of checking for an existing map?

Bill

Java Resources at www.wbrogden.com
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Getting online users list
 
Similar Threads
Help with Chat Program, update user list
How to block multiple logins of the same user
Keeping track of Logged users
Managing Session
org.hibernate.LazyInitializationException