aspose file tools*
The moose likes Servlets and the fly likes How to get a HttpSession from a Session ID ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "How to get a HttpSession from a Session ID ?" Watch "How to get a HttpSession from a Session ID ?" New topic
Author

How to get a HttpSession from a Session ID ?

James Adams
Ranch Hand

Joined: Sep 12, 2003
Posts: 188
I have a user's session ID stored in a bean. I want to be able to get the actual HttpSession object that this identifies, in order to invalidate it. Is there a way, besides using HttpSessionContext.getSession(), which is deprecated ?

Thanks in advance...


--James
Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
As docs says HttpSessionContext.getSession() is Deprecated with no replacement.

Infact the Id you get from the method getId() is not reliable. As docs says, Id is assigned by the servlet container and is implementation dependent.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

I use a session listener to store a reference to the session in a HashMap that lives in a singleton object.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to get a HttpSession from a Session ID ?
 
Similar Threads
Why cann��t get the original session object in second Servlet?
Getting HttpSession object from SessionContext
Getting HTTP Session by using Session ID
wich session tracking techniwue to use
Get session object from session ID