What do these calls actually mean in terms of session?
System.out.println(\"print1: \"+request.getSession().getId());
System.out.println(\"print2: \"+request.get
First line will return the "session id" on server.
The second line will return session object. So what will be printed on system.out would be request.getSession(false).toString();
The default implementation of toString
returns the "object id". Object id
in terms of session is not the same as session id
. Session could be serialized and replicated across the cluster so on each node of the cluster on each JVM it may have it's own object id (but should have same session id).
Calling get session with boolean is explained here: http://docs.oracle.com/javaee/6/api/javax/servlet/http/HttpServletRequest.html#getSession(boolean)