Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to get a HttpSession from a Session ID ?

 
James Adams
Ranch Hand
Posts: 188
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2874
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I use a session listener to store a reference to the session in a HashMap that lives in a singleton object.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic