[Switch] session management in Tomcat

Source: Internet
Author: User

Address: http://blog.csdn.net/iloveqing/article/details/1544958

When a sesson starts, the servlet container will create an httpsession object to transfer these httpsession objects from the memory to the file system or database in some cases, load them into the memory when you need to access them. The two benefits of this solution are as follows: memory consumption is reduced, and session data can be recovered from the file system or database when the web server fails.
For session management, the kitten provides two implementation classes: org. Apache. Catalina. session. standardmanager and org. Apache. Catalina. session. persistentmanager.
Standardmanager-is the default method. When the Tomcat server is restarted or overloaded, the session object is saved
<% Catalina_home %>/work/Catalina/honstname/applicatonname/sessions. Ser (default) file, each object corresponds to a file, with the session ID as the file name. For example:

<Context Path = "/helloapp" docbase = "helloapp" DEBUG = "0" reloadable = "true">
<Manager classname = "org. Apache. Catalina. session. standardmanager" DEBUG = "0"
Maxactivesessions = "-1" checkinterval = "60"/>
</Context>
Parameter description: checkinterval-interval for checking whether the session has expired, in seconds. The default value is 60 seconds;
Maxactivesessions-number of active sessions.

Persistentmanager-provides more flexible management methods and fault tolerance capabilities. You can back up sessions to the session store in time to control the number of sessions in the memory.
Kitten also provides an interface for implementing persistent session store, org. apache. catalina. store. Currently, two implementation classes are provided: Org. apache. catalina. filestore and org. apache. catalina. jdbcstore.
Server. xml configuration file store-

<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: saveonrestart-whether to save all sessions to files when the server is closed;
Maxactivesessions-number of active sessions;
Minidleswap/maxidleswap-session is inactive for the shortest/long time (s), and the sesson object is transferred to the file store;
Maxidlebackup-Back up session after this time. (-1 indicates 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.