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)