Chinaunix首页 | 论坛 | 博客
  • 博客访问: 774650
  • 博文数量: 160
  • 博客积分: 2516
  • 博客等级: 大尉
  • 技术积分: 1511
  • 用 户 组: 普通用户
  • 注册时间: 2004-10-24 17:58
文章分类

全部博文(160)

文章存档

2019年(2)

2018年(3)

2017年(15)

2016年(3)

2015年(11)

2014年(3)

2013年(1)

2012年(3)

2011年(17)

2010年(25)

2009年(17)

2008年(13)

2007年(14)

2006年(21)

2005年(10)

2004年(2)

分类: Java

2011-04-21 09:34:22

 Configuring a Persistent Session Manager 
 The Persistent Session Manager is configured through the    element in the Context descriptor of a Web application. This element must be configured as a subelement of the    element within the application’s Context descriptor XML file. The    element can placed in the global  context.xml  found in the   $CATALINA_HOME/conf  directory (applied globally to all Web applications in the server) or in a   context.xml  file placed in the META-INF directory of the application’s WAR file

The    Element 
 The following table describes the most common attributes of the    element that are available for configuration.
Attribute Description Required?

className The Java programming language class that implements the 
Persistent Session Manager. This should be org.apache
.catalina.session.PersistentManager.
Yes
algorithm The algorithm used for generating the session IDs. Default of 
MD5 should be adequate for almost all cases.
No
distributable Default is false. A element in an applica-
tion’s web.xml is equivalent to setting this to true. When true, 
the Session Manager will enforce that all session attributes be 
 serializable.
No
entropy The seed (string) value used in generating randomized ses-
sion IDs by the persistence manager. Default is a random 
computed value. You can specify any long string as a seed.
No
maxActiveSessions The ceiling on the number of active sessions before swapping 
out of the session via the Persistent Session Manager begins. 
The default value of –1 allows an unlimited number of active 
sessions.
No
minIdleSwap The minimum number of seconds before a session will be 
 considered for swapping. The default value of –1 enables 
swapping at any time. Make sure this is maxIdleSwap if you 
specify it.
No
maxIdleSwap The maximum number of seconds before a session is eligible to 
be swapped out to the Store. Used with minIdleSwap to tune 
the session persistence mechanism. The default value is –1, 
and the session will be swapped without an eligibility check.
No
maxIdleBackup The number of seconds since a session was last active before it 
is backed up on the Store. Note that sessions that are backed 
up are not removed from memory — they are not swapped. 
This can be used to avert a sudden crash, as the backed up ses-
sions will be restored from the Store upon the next startup. The 
default value of −1 will disable the backup action altogether.
No
randomClass The implementation of java.util.Random to use. By 
default, java.security.SecureRandom is used.
No
saveOnRestart If this is set to true, Tomcat will save all the active sessions 
to the Store upon shutdown, and will reload the sessions 
(except the expired ones) from the Store on startup. The 
default is true.
No
sessionIdLength The length of the session ID created by the Session Manager 
instance. Default is 16.
No

The    element can have only one subelement, as described in the following table.
Subelement Description How Many?
Store Used by the Persistent Session Manager to determine how and where to save the session. Currently, the only options available for a Store implementation are org.apache.catalina.session.FileStore or org.apache.catalina.session.JDBCStore.
Store  uses object serialization to store the session. The following hands-on example uses the   FileStore Store implementation. By default, the   FileStore ’s serialized session information is placed under the $CATALINA_HOME/work////  directory. You can customize the directory for use by setting the   directory  attribute of the   Store element.
 
Hands-On Configuration with the Persistent Session Manager 
 To configure the Persistent Session Manager, it is necessary to add a    element definition into the Context descriptor of the Web application. In this example, the default servlet and JSP examples Web application will be used. 
 The easiest way to add a Context descriptor to the examples application is to create a   $CATALINA_HOME/webapps/examples/META-INF/context.xml  file containing the following:
 
  
         saveOnRestart=’true’
         maxActiveSessions=’3’
         minIdleSwap=’0’
         maxIdleSwap=’60’
         maxIdleBackup=’0’>
  
  

This configures a Persistent Session Manager that will allow up to three active sessions before activating 
session swapping. Any session is available for swapping at any time. All idle sessions will be swapped 
within 60 seconds. An active session is backed up regularly; a value of   0  indicates that sessions should be 
backed up immediately after being used. 

context.xml:
        
    
阅读(2659) | 评论(0) | 转发(0) |
0

上一篇:被遗忘的HTML标签

下一篇:fail2ban

给主人留下些什么吧!~~