`

设置session过期的各种方式(主要看weblogic的方式)

阅读更多

一.web.xml

        设置WEB应用程序描述符web.xml里的<session-timeout>元素。这个值以分钟为单位,并覆盖weblogic.xml中的TimeoutSecs属性,此例表示Session将在54分钟后过期。

<session-config>
    <session-timeout>54</session-timeout>
</session-config>

        当<session-timeout>设置为-2,表示将使用在weblogic.xml中设置的TimeoutSecs这个属性值。

        当<session-timeout>设置为-1,表示Session将永不过期,而忽略在weblogic.xml中设置的TimeoutSecs属性值。该属性值可以通过console控制台来设置。

 

二.weblogic.xml

        设置WebLogic特有部署描述符weblogic.xml的<session-descriptor>元素的TimeoutSecs属性。这个值以秒为单位。该文件放在项目的web-inf下。

<session-descriptor>
   <session-param>
      <param-name>TimeoutSecs</param-name>
      <param-value>3600</param-value>
   </session-param>
</session-descriptor>

        默认值是3600秒

 

三.jsp中控制

        session.setmaxinactiveinterval(7200); session是默认对象,可以直接引用,单位秒s。

 

四.servlet中控制

httpsession session = request.getsession();
session.setmaxinactiveinterval(7200);

        单位秒s。

 

文章来源:http://blog.sina.com.cn/s/blog_67aaf4440101cqyh.html

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics