Three commonly used domain objects in Servlet
Object type | Object name |
---|---|
HttpServletRequest | request |
HttpSession | session |
ServletContext | application |
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.