Four domain objects of jsp
Object type | Object name |
---|---|
PageContext | pageContext |
HttpServletRequet | request |
HttpSession | session |
ServletContext | application |
pageContext domain
Create: It is one of the nine built-in objects and exists by default.
Destroy: The current page is executed
. Scope: Only valid in the current page
request domain
Create: The client sends a request to the server, and the server creates a request object.
Destruction: The server will destroy the request object after responding to this request
. Scope: only valid in the current request
session domain
Creation: the first time the server calls getSession(); the session domain is created and saved in the server memory for
destruction:
- Abnormally shut down the server (normally shut down the session will be serialized, restart the server session will be deserialized)
- The session expired by default 30 minutes
- Manually call session.invalidate();
Note: If you close the browser and visit again, you will not find the session id of the session instead of the session being destroyedScope: Open the browser session to start, close the browser session to end. Valid throughout the session
application domain
Creation: The server creates an object ServletContext class belonging to the web application for each WEB application when the server starts.
Destruction: The server is closed or the project is removed from the server.
Scope: It is valid on the entire server.
The nine built-in objects of jsp
One, what are built-in objects?
Some objects are frequently used in jsp development, such as ServletContext HttpSession PageContext, etc. It will be particularly cumbersome if you have to create these objects yourself every time you use them.
Therefore, when SUN is designing JSP, it will automatically help developers to create these objects after the JSP page is loaded. Developers only need to use the corresponding objects to call the corresponding methods. The objects created by the system are called built-in objects.For example, in the servlet program, if the developer wants to use the session object, it must be obtained through request.getSession(), while in the jsp program, the session can be used directly (the name of the session object created by the system is called session). The corresponding method is sufficient, such as: session.getId().
Object type | Object name |
---|---|
PageContext | pageContext |
HttpServletRequet | request |
HttpSession | session |
ServletContext | application |
HttpServletResponse | response |
ServletConfig | config |
Throwable | exception |
Object(this) | page |
JspWriter | out |
pageContext
Role: Get the other 8 built-in objects
There are still many incomplete places to be updated later