To modify the default session timeout value for all Java web application deployed on Apache Tomcat server, open the web.xml file in the conf directory in Tomcat installation location – typically under this path on Windows:

c:\Program Files\Apache Software Foundation\Tomcat 9.0\conf\

web xml in Tomcat conf

Open the web.xml file using a text editor. Search for the session-timeout keyword (include the hyphen) and you will see this section:

<session-config>
    <session-timeout>30</session-timeout>
</session-config>
Now you change the session timeout to a value you wish, in minutes (you can see the default time out value is 30 minutes).

Save the file and restart the server for the change takes effect. All web applications that do not override session timeout configuration will be affected.

 

NOTE: If you are running Tomcat in Eclipse IDE, you need to edit the web.xml file in different location, as Eclipse makes a copy of server configuration files in the workspace, typically in this path:

/Servers/Tomcat v9.0 Server at localhost-config

You can check the exact path in Eclipse by double clicking on the server name in the Servers view to open the Server editor. Look for the path under Configuration path, as shown below:

Tomcat configuration path



To change session time out value for a specific web application, read this article.

 

Other Tomcat Tutorials:


About the Author:

is certified Java programmer (SCJP and SCWCD). He started programming with Java in the time of Java 1.4 and has been falling in love with Java since then. Make friend with him on Facebook and watch his Java videos you YouTube.



Add comment