In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly explains the "introduction of the four scopes of JavaWeb". The content of the explanation in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn the introduction of the four scopes of JavaWeb.
1. PageContext domain:
The scope is the entire JSP page, the smallest of the four scopes; the life cycle starts when a request to JSP is made and is destroyed when the response ends.
Second, the ServletRequest domain:
The scope is the entire request chain (request forwarding also exists); the life cycle is created by the server before the service method call, passing in the service method. The whole request ends and request's life ends.
3. HttpSessiondomain:
The scope of action is a conversation. The life cycle is when the request.getSession () method is called for the first time, the server checks to see if there is already a corresponding session, and if not, creates a session in memory and returns. When the session is not used for a period of time (the default is 30 minutes), the server destroys the session. If the server shuts down abnormally (forcibly shut down), the session that has not expired will also be destroyed. If you call invalidate () provided by session, you can destroy the session immediately.
Note: when the server shuts down normally and then starts, the Session object will be passivated and activated. At the same time, if the server passivation time is within the default destruction time of session, then session still exists after activation. Otherwise, Session does not exist. If JavaBean data is passivated by session and Serializable is not realized, it will disappear when Session is activated.
IV. ServletContext domain:
The scope of action is the entire Web application. When the Web application is loaded into the container, a ServletContext object representing the entire web application is created, and when the server is shut down or the Web application is removed, the ServletContext object is destroyed.
In short, the four scopes of JavaWeb can be summarized as follows:
PageContext: valid on this page, but invalid if you jump out of the page
ServletRequest: cross-page function, generally used for form submission, etc.
HttpSession: use during a certain session
ServletContext: always valid, invalidated after shutting down the server.
Thank you for your reading. The above is the content of "introduction to the four scopes of JavaWeb". After the study of this article, I believe you have a deeper understanding of the introduction of the four scopes of JavaWeb, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.