简体   繁体   中英

Java - time length of an attribute set by ServletContext

might anyone know what is the time length of an attribute set by ServletContext. For example an attribute set by HttpSession can be up to 30 mins long. So, how long is the lifespan of a attribute set ServletContext?

只要部署了应用程序,它就会存在。

There are several scopes (scope objects) in Servlet specifications, which allow you to share information between your web components via attributes:

  • Request scope - tied to the lifetime of request, used by components handling the request. (subtype of javax.servlet.ServletRequest)
  • Session scope - tied to the lifetime of session, used by components handling request, which is tied to the session( javax.servlet.HttpSession)
  • Application scope or web scope - tied to the lifetime of web application, and shared with all other servlet in your application. This is scope for ServletContext attributes. (Stored in the memory of the Servlet Container - javax.servlet.ServletContext)

There is also page scope, but it is only visible to JSP pages itself.(javax.servlet.jsp.JspContext)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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