简体   繁体   English

javax.servlet.http.HttpServletRequest 中的 HttpSession 如何工作

[英]How does HttpSession from javax.servlet.http.HttpServletRequest work

How is a session identified in a javax HttpSession ?如何在 javax HttpSession 中标识会话? Let's say I store something in a session.假设我在会话中存储了一些东西。 Firstly how long will it stay there.首先它会在那里停留多久。 I think I do not enter any timeout.我想我没有进入任何超时。 So what will be default.那么什么将是默认的。 And how is the session identified.以及如何识别会话。 Is it by cookie ?是通过 cookie 吗? What if I use multiple browsers.如果我使用多个浏览器怎么办。 Will there be an own session for every single browser ?每个浏览器都有自己的会话吗? So if I use Chrome for 5 minutes and store stuff in the session, then I use IE the session will be empty again ?因此,如果我使用 Chrome 5 分钟并在会话中存储内容,那么我使用 IE 会话将再次为空?

Additionally I want to add , it seems if I shutdown the server the session automatically gets deleted, so session stuff seems only to be saved in RAM.另外我想补充一点,似乎如果我关闭服务器,会话会自动被删除,因此会话内容似乎只保存在 RAM 中。

Thanks for your help in advance.提前感谢您的帮助。

Normally session are identified with a cookie, so:通常会话是用 cookie 标识的,所以:

  1. yes, if you change browser you'll open a new session and you'll lost every data stored in previous session: it's another session!是的,如果您更改浏览器,您将打开一个新会话,并且您将丢失先前会话中存储的所有数据:这是另一个会话!
  2. yes, session data are stored in RAM, f it is not explicitly saved (directly or indirectly) in a DB or File or other data storage.是的,会话数据存储在 RAM 中,如果它没有明确保存(直接或间接)在数据库或文件或其他数据存储中。

Finally, the default timeout depends on the server used, generally is 30 min.最后,默认超时时间取决于所使用的服务器,一般为 30 分钟。 The customization of the timeout depends, again, on the server used.超时的自定义同样取决于所使用的服务器。 In tomcat/tomee for example you can change this value on application based (in the web.xml a deploy descriptor of java galaxy)例如,在 tomcat/tomee 中,您可以基于应用程序更改此值(在 web.xml 中是 java Galaxy 的部署描述符)

暂无
暂无

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

相关问题 为什么spring-boot-3会报javax.servlet.http.HttpServletRequest ClassNotFoundException - Why does spring-boot-3 give javax.servlet.http.HttpServletRequest ClassNotFoundException 使用JSF提交数据表值,并通过javax.servlet.http.HttpServletRequest访问它 - Submit datatable values with JSF and access it through javax.servlet.http.HttpServletRequest RESTEASY003880:找不到类型的上下文数据:javax.servlet.http.HttpServletRequest - RESTEASY003880: Unable to find contextual data of type: javax.servlet.http.HttpServletRequest 类型 javax.servlet.http.HttpServletRequest 不存在,gradle springfox-swagger2: 3.0 - Type javax.servlet.http.HttpServletRequest not present, with gradle springfox-swagger2: 3.0 HTTP状态500-java.lang.ClassCastException:rest.rest页面无法转换为javax.servlet.http.HttpServletRequest - HTTP Status 500 - java.lang.ClassCastException: rest.rest Page cannot be cast to javax.servlet.http.HttpServletRequest Java - javax.websocket.Session 和 javax.servlet.http.HttpSession 是否使用相同的 JSESSIONID? - Java - Does javax.websocket.Session and javax.servlet.http.HttpSession use the same JSESSIONID? 使javax.servlet.http.HttpSession在某些页面上不超时 - Make javax.servlet.http.HttpSession not timeout on certain pages java.lang.NoSuchMethodError:javax.servlet.http.HttpServletRequest.getPart - java.lang.NoSuchMethodError: javax.servlet.http.HttpServletRequest.getPart java.lang.NoSuchMethodError:javax.servlet.http.HttpServletRequest.getParts() - java.lang.NoSuchMethodError: javax.servlet.http.HttpServletRequest.getParts() @Controller导致java.lang.NoClassDefFoundError:javax / servlet / http / HttpServletRequest - @Controller causing java.lang.NoClassDefFoundError: javax/servlet/http/HttpServletRequest
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM