Session creation:
Recently in the statistics server online, by counting the current number of server sessions to achieve a Httpsessionlistener, the client first access to the background JSP or servlet will call the Sessioncreated () method, That is, Tomcat automatically creates the session, (sometimes we need to create a session after the user logs in, no Tomcat is required to create the session, the ability is limited I don't currently find a way to manually control when the session is created). The session created at this time can be obtained through request.getsession ().
Every request to access a JSP, or a servlet, creates a session, which means that accessing static resources such as IMG and HTML does not create a session.
Expiration of Session:
Calling the Session.invalidate () method invalidates the current session, and this method invokes the Sessiondestory () method in the Httpsessionlistner, but at this point the session is not purged from memory. The server will at some point at a time to clear the failed session out of memory (IBID., how to manually clear the session out of memory, forget everyone to tell).
Tomcat Session Thinking