Tomcat Session Thinking

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.