Get all exisiting Sessions

Hi all,
Here is the situation:
I'm developing an online intranet project using Servlets and JSP in which the users logs in and works. I'm also using the sessions for each user. I want to make it a bit secured, like if a user logs in with the username 'X' and password 'y' successfully to the system, now in another system or in the same system if another/same user tries to log in(with 'X' and 'y'), it should fail. So that each user have only one session.

I tried to implement it using a Map(key=loginName, value=sessionID).
When a user logs in, an entry into the map is made; and when he logs off, the entry is removed.
It worked fine until the user logs in and logs off correctly, but when the session is expired or the user closes the browser window instead of logging off, I'm not able to remove the entries in the map.

I tried to use the HttpServletContext Interface to get session using its Id, but it also failed. And the interface is deprecated, so I should no use as per requirements.

Is there any way to get all the existing session IDs (or even sessions) from the servlet container? and how to access the container?

I'm using Apache Tomcat 5.5 as the server...

A little code snippet would be a lot for me...

Thanks N regards,

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!