[Tomcat] Session expiration time setting

Tomcat adopts the database connection pool technology. When the user does not have time to operate the database for a certain period of time, the connection is automatically closed. This is to make better use of resources and prevent the waste of precious database connection resources.
You can use the following three ways to set the expiration time of this connection (Session): The


first two are to modify the configuration file conf of tomcat
1. When defining the context in server.xml, use the following definition:
xml code
<Context path="/ livsorder" docBase="/home/httpd/html/livsorder"      
  defaultSessionTimeOut="3600" isWARExpanded="true"      
  isWARValidated="false" isInvokerEnabled="true"      
  isWorkDirPersistent="false"/>  
3600 seconds=1 hour
2. In web Specified by parameters in .xml:
xml code
<session-config>    
    <session-timeout>30</session-timeout>      
</session-config>  


where 30 means 30 minutes


3.





HttpSession ses = request.getSession();   
ses.setMaxInactiveInterval(10);  


Set the unit to seconds, and set it to -1 to never expire.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325772312&siteId=291194637