0

Can we retrieve a session corresponding to a particular session ID?

I am getting session ID using

session.getId();

I want to retrieve the session corresponding to this ID.

George Cummins
  • 28,485
  • 8
  • 71
  • 90
user2269361
  • 61
  • 1
  • 1
  • 2

2 Answers2

0

You would need to implement a SessionListener and store a map of the sessions sessionId->HttpSession.

Here is a code example of a SessionLisetener: http://www.java2s.com/Code/Java/Servlets/Servletsessionlistener.htm

fmodos
  • 4,472
  • 1
  • 16
  • 17
0

JSP provides couple of implicit objects and you can access without any additional effort: http://docs.oracle.com/javaee/5/tutorial/doc/bnahq.html#bnaij So, if you want to access to your current session just use the following code:

session.getAttribute("name");
session.setAttribute("name",  "value");
Michael
  • 10,063
  • 18
  • 65
  • 104