The default session validity period for Tomcat is 30 minutes. ================================================== You can go to the "tomcat installation directory "/CONF/web. set and view in the XML file.CodeAs follows (the unit of time is minute ): <session-config> <session-Timeout> 30 </session-Timeout> </session-config> ================ ========================== In addition, you can set the Tomcat session validity period in three ways: 1. In tomcat/CONF/web. modify the value of session-timeout in XML, which is the global default of Tomcat; can also be in the WEB-INF/web. set the time used by the application in XML, with Tomcat/CONF/web. the XML settings are identical. 2. on the server. use the following definition when defining context in XML (modify the defaultsessiontimeout value, in seconds ): <context Path = "/livsorder" docbase = "/home/httpd/html/livsorder" defaultsessiontimeout = "3600" iswarexpanded = "true" iswarvalidated = "false" isinvokerenabled = "true" isworkdirpersistent = "false"/> 3.ProgramUsing Servlet API: httpsession ses = request. getsession (); SES. setmaxinactiveinterval (10); // set the unit to seconds and set it to-1 and never expire.