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.