Search This Blog

Monday, 16 November 2009

session management on WebSphere

WebSphere adds a prefix to the session identifiers, which will not be included by the getId method of the HttpSession object.

This would cause problems in such cases when you need to enable a process external to the browser to work inside an already existing session created by an user logged on the web interface.

HttpSession session = request.getSession(true);
String standardSessionID = session.getId();
//standardSessionID does not contain the cache prefix

String header = request.getHeader("Cookie");
//header contains the string "JSESSIONID="

String fromHeaderSessionID = header.substring(11);
//fromHeaderSessionID contains the WebSphere cache prefix
//and can be sent to the server as a JSESSIONID cookie or as a part of the url,
//as in the string 
Strig url = ";jsessionid=" + fromHeaderSessionID;

No comments:

Post a Comment