Home > Java > javaTutorial > body text

What are the four major scopes of java?

little bottle
Release: 2020-09-18 13:39:34
Original
11176 people have browsed it

The four major scopes of Java are: 1. PageContext scope; 2. ServletRequest scope; 3. HttpSession scope; 4. ServletContext scope.

What are the four major scopes of java?

Java’s four major scopes are: PageContext, ServletRequest, HttpSession, and ServletContext. Please follow the editor to learn about the four major scopes of Java.

First calculate according to the scope:

is PageContext (jsp page)

If there are objects with the same name in different scopes, the system’s search order is page->request->session->application 

application scope: The largest scope among all scopes. Since all servlets share a servletcontext object, all multiple servlets can share data between different servlets through servletcontext. It is a global variable

httpsession scope: The second largest scope, (session scope) when the request.getSession() method is called for the first time, the server will check whether there is already a corresponding session. If not, create a session in memory and return. When the session is not used for a short period of time (default 30 minutes), the server will destroy the session. If the server is shut down abnormally, unexpired sessions will also be destroyed. If you call the invalidate() method provided by the session, the session can be destroyed immediately.

servletRequest scope: The third largest scope, sharing data in the entire request chain. The longest time is used to hand over the processed data in the servlet to jsp for display. At this time, the parameters It can be placed in the servletRequest domain and brought over

PageContext scope: The smallest domain can obtain the other eight built-in objects. It can be considered as an entry object and can obtain all other domains. data in. It can jump to other resources. It provides forward and sendRedirect methods, which simplifies forwarding and redirection operations. It represents the page context. This object is mainly used to access shared data between jsps. It starts when a request to jsp is made. Destroyed at the end of the response

The above is the detailed content of What are the four major scopes of java?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!