In java appplication, JSESSIONID use as the session id. JSESSIONID is a cookie generated by Servlet container like Tomcat or Jetty and used for session management in J2EE web application for http protocol. So below code segment shows how to generate a new session out of old session.
private void regenrateSession(HttpServletRequest request) {
HttpSession oldSession = request.getSession();
Enumeration attrNames = oldSession.getAttributeNames();
Properties props = new Properties();
while (attrNames != null && attrNames.hasMoreElements()) {
String key = (String) attrNames.nextElement();
props.put(key, oldSession.getAttribute(key));
}
oldSession.invalidate();
HttpSession newSession = request.getSession(true);
attrNames = props.keys();
while (attrNames != null && attrNames.hasMoreElements()) {
String key = (String) attrNames.nextElement();
newSession.setAttribute(key, props.get(key));
}
}
http://javarevisited.blogspot.com/2012/08/what-is-jsessionid-in-j2ee-web.html#ixzz3JRxDttxm
http://blog.credera.com/technology-insights/java/broken-authentication-session-management/
No comments:
Post a Comment