Pranesh
Pranesh

Reputation: 71

How does Tomcat manage sessions?

As I restarts tomcat container my application should go to index page( or login page) if I stop tomcat but instead it allows me to go to that view . It only redirects to index when I remove tomcat from eclipse and recreate tomcat server and start. How does tomcat manage session that I have created in previous server start ?

Upvotes: 0

Views: 2352

Answers (1)

Svetlin Zarev
Svetlin Zarev

Reputation: 15713

The default tomcat configuration is to persist the session state to disk and reload it on next start. From the tomcat documentation [1]:

Whenever Apache Tomcat is shut down normally and restarted, or when an application reload is triggered, the standard Manager implementation will attempt to serialize all currently active sessions to a disk file located via the pathname attribute. All such saved sessions will then be deserialized and activated (assuming they have not expired in the mean time) when the application reload is completed.

This is configurable and can be disabled:

Every web application by default has standard manager implementation configured, and it performs session persistence across restarts. To disable this persistence feature, create a Context configuration file for your web application and add the following element there:

<Manager pathname="" />

[1] The official documentation: http://tomcat.apache.org/tomcat-7.0-doc/config/manager.html#Disable_Session_Persistence

Upvotes: 4

Related Questions