Related information:
"21-Day Learning Java Web Development"
Session Object
Set and get session life cycle
1. The session's life cycle can be set through the Setmaxinactiveinterval () method of the Session object.
2. The life cycle of the session can be obtained by Getmaxinactiveinterval () method.
sessiondemo.jsp
1 <%@ Page Language="Java"ContentType="text/html;charset=gb2312" %>2 <HTML>3 <Head>4 <title>Set and get session activity time</title>5 </Head>6 <Body>7 <%8 Session.setmaxinactiveinterval ( -*2);//Set session Maximum active time is 2 minutes9 int Time =session.getmaxinactiveinterval ();//Get session Maximum activity timeTen Out.println ("The maximum event time for the session is:"+ Time+"seconds");//output Session Maximum active time One %> A </Body> - </HTML>
View Code
Java-jsp set the Session object of the built-in object and get the session life cycle