JAVA-JSP内置对象之session对象设置并获得session生命周期

 

相关资料:
《21天学通Java Web开发》

session对象
设置并获得session生命周期
1.通过session对象的setMaxInactiveInterval()方法可以设置session的生命周期。
2.可以通过getMaxInactiveInterval()方法来获得session的生命周期。

 

SessionDemo.jsp

 1 <%@ page language="java" contentType="text/html;charset=gb2312" %>
 2 <html>
 3 <head>
 4   <title>设置并获得session活动时间</title>
 5 </head>
 6 <body>
 7   <%
 8     session.setMaxInactiveInterval(60*2);//设置session最大活动时间为2分钟
 9     int time = session.getMaxInactiveInterval();//获得session最大活动时间
10     out.println("session最大活动时间为:"+time+"");//输出session最大活动时间
11   %>
12 </body>
13 </html>
View Code

 

相关文章:

  • 2021-06-26
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-01
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-12-06
  • 2021-11-29
  • 2021-09-20
相关资源
相似解决方案