Tomcat/weblogic session失效时间的几种设置方法
一、在容器中設置
tomcat中配置server.xml中定義context時采用如下定義:
<Context path="/livsorder" docBase="/home/httpd/html/livsorder"?defaultSessionTimeOut="3600" isWARExpanded="true"?isWARValidated="false" isInvokerEnabled="true"?isWorkDirPersistent="false"/>
weblogci中設置weblogic特有部署描述符weblogic.xml的<session-descriptor>元素的timeoutsecs 屬性。這個值以秒為單位
<session-descriptor>
<session-param>
<param-name>timeoutsecs</param-name>
<param-value>2600</param-value>
</session-param>
</session-descriptor>
默認值是2600秒
二、web應用設置,優先級比容器中高
設置web應用程序描述符web.xml里的<session-timeout>元素。這個值以分鐘為單位,并覆蓋 weblogic.xml中的timeoutsecs屬性
<session-config>
<session-timeout>24</session-timeout>
</session-config>
此例表示session將在24分鐘后過期 ,默認設置是30分鐘。當<session- timeout>設置為-2,表示將使用在weblogic.xml中設置的timeoutsecs這個屬性值。當<session- timeout>設置為-1,表示session將永不過期,而忽略在weblogic.xml中設置的timeoutsecs屬性值。該屬性值可以通過console控制臺來設置
三、應用代碼中設置,優先級最高
jsp中控制
session.setmaxinactiveinterval(7200);
session是默認對象,可以直接引 用,單位秒s
4,servlet中控制
httpsession session = request.getsession();
session.setmaxinactiveinterval(7200);
單位秒 s
轉載于:https://www.cnblogs.com/Neil223/p/5237879.html
總結
以上是生活随笔為你收集整理的Tomcat/weblogic session失效时间的几种设置方法的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: oc知识点 类的扩展
- 下一篇: 42.递归算法---数的划分