Session Management _session in Tomcat

Source: Internet
Author: User
Tags session id sessions tomcat server
Session Management
When a sesson begins, the servlet container creates a HttpSession object, in some cases transferring the HttpSession objects from memory to the file system or the database, and loading them into memory when needed. The benefits of this are two points: saving memory consumption, and when the Web server fails, you can also restore session data from the file system or database.
For the session management, The kitten offers two implementation classes: Org.apache.catalina.session.StandardManager and Org.apache.catalina.session.PersistentManager.
Standardmanager-is the default method, when the Tomcat server restarts or overloads, the session object is saved to the
<%catalina_home%>/work/catalina/honstname/applicatonname/sessions.ser (default) file, each object corresponds to a file, with the session ID as the filename, For example:

<context path= "/helloapp" docbase= "HelloApp" debug= "0" reloadable= "true" >
<manager classname= "Org.apache.catalina.session.StandardManager" debug= "0"
maxactivesessions= "-1" checkinterval= "/>"
</Context>
Parameter Description: checkinterval-Check whether the session expires at the interval, in seconds, the default value is 60 seconds;
maxactivesessions-the number of sessions that can be active.

Persistentmanager-Provides a more flexible management approach with fault tolerance, which can be backed up into the session store in time to control the number of sessions in memory.
The kitten also provides an interface to implement the persistent session store, Org.apache.catalina.Store, currently offers two specific implementation classes: Org.apache.catalina.FileStore and Org.apache.catalina.JDBCStore.
The configuration file Store in Server.xml-

<context path= "/helloapp" docbase= "HelloApp" debug= "0" reloadable= "true" >
<manager classname= "Org.apache.catalina.session.PersistentManager" debug= "0" saveonrestart= "true"
maxactivesessions= "-1" minidleswap= "-1" maxidleswap= "-1" maxidlebackup= "-1" >
<store classname= "Org.apache.catalina.session.FileStore" directory= "Mydir"/>
</Manager>
</Context>
Parameter description: When the saveonrestart-server shuts down, whether all sessions are saved to the file;
maxactivesessions-the number of sessions that can be active;
Minidleswap/maxidleswap-session is in the inactive state for shortest/long time (s), the Sesson object is transferred to the file store;
maxidlebackup-over this time, the session is backed up. (-1 means no limit)

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.