简体   繁体   English

Tomcat如何管理会话?

[英]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 . 当我重新启动tomcat容器时,如果我停止了tomcat,我的应用程序应该转到索引页面(或登录页面),但它允许我进入该视图。 It only redirects to index when I remove tomcat from eclipse and recreate tomcat server and start. 仅当我从Eclipse中删除tomcat并重新创建tomcat服务器并启动时,它才会重定向到索引。 How does tomcat manage session that I have created in previous server start ? tomcat如何管理在先前服务器启动中创建的会话?

The default tomcat configuration is to persist the session state to disk and reload it on next start. 缺省的tomcat配置是将会话状态持久保存到磁盘,并在下次启动时重新加载它。 From the tomcat documentation [1]: 从tomcat文档[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. 只要Apache Tomcat正常关闭并重新启动,或者触发了应用程序重载,标准的Manager实施就会尝试将所有当前活动的会话序列化为通过pathname属性定位的磁盘文件。 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 [1]官方文档: http : //tomcat.apache.org/tomcat-7.0-doc/config/manager.html#Disable_Session_Persistence

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM