Scope range size of four domains: PageContext (page field) < Request < Session < ServletContext (application domain)
First, ServletContext
1. Life cycle: When a Web application is loaded into a container, a ServletContext object representing the entire web app is created, and the ServletContext object is destroyed when the server shuts down or the Web app is removed.
2, the scope of action: the entire Web application.
3. Common functions:
(a) forwarding between different servlets
(b) Read the resource file.
Second, Request domain
1. Life cycle: Created by the server before the service method call, incoming service method. The entire request is over, requesting the end of life.
2, the scope of action: The entire request chain (Request forwarding also exists).
3. Common functions: Share data throughout the request chain. For example, when the data processed in the servlet is given to the JSP display, the parameters can be placed in the request domain with the past.
Third, Session field
1, life cycle: When the first call to the Request.getsession () method, the server will check if there is already a corresponding session, if not in memory to create a session and return. 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 gracefully (forcibly closed), the session with no expiration will be destroyed. If the invalidate () provided by the session is called, the session can be destroyed immediately.
Note: The server shuts down properly and then starts, and the session object is deactivated and activated. In the meantime, if the server passivation time is within the session default destruction time, then the activation session still exists. Otherwise the session does not exist. If the JavaBean data is not implemented when the session is deactivated, serializable will disappear when the session is activated.
2. Scope of action: one session.
3. Common functions: Create a unique memory space for your browser, where you save session-related information.
Four, PageContext domain
1. Life cycle: When a request to a JSP starts, it is destroyed when the response ends.
2, the scope: the entire JSP page, is the four largest scope of the smallest one, that is, more than this page can not be used. (so it is not possible to use the PageContext object to pass parameters to other pages.)
3. Common functions:
(1) Get the other eight implicit objects, which can be considered as a portal object.
(2) Get data from all of its domains
(3) Jump to other resources, which provide forward and include methods to simplify redirection and forwarding operations.
Review of javaweb-four-domain objects