Another way (and not the best way) is to call "changeSessionId (existingSession)" org.apache.catalina.session.StandardManager , which will change the session ID of the current session to a new randomly generated session ID.
To call this method, you must use the StandardManager Mbean. See Tomcat MBeans
Pseudocode:
ObjectName contextObjectName = new ObjectName ("Catalina: type = Manager, path = / whatever, host = whateverhost");
mbeanServer.invoke (contextObjectName, "changeSessionId", new Object [] {session}, new String [] {"javax.servlet.http.HttpSession"});
Ritesh
source share