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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM