What is a session?
- Session represents a client-to-server conversation
- The session in the Web refers to the amount of time that a user has spent browsing a website, from entering the site to the browser closing, that is, the time it takes for the user to browse the site.
- As you can see from the above definition, the session is actually a specific time concept
- The session of different users is stored inside the server
Session Object
- The session object is a JSP built-in object.
- The session object is created automatically when the first JSP page is loaded, and sessions management is completed.
- Open a browser from a client and connect to the server to start, to the client close the browser to leave the end of this server, known as a session.
- When a client accesses a server, it may switch between several pages of the server, and the server should know by some means that it is a client and needs a session object.
- The session object is an instance of the Htppsession class.
The following are common methods for session objects:
The life cycle of the session
Create: When a client accesses a JSP or servlet for the first time, the server creates a SessionID for the current session, and each time the client sends a request to the server, it carries the SessionID in the past. This seesionid will be verified by the server.
Activities:
- A new page that is opened by a hyperlink in a session belongs to the same session.
- As long as the current session page does not close all, reopen the new browser window to access the same project resource when it belongs to the same session.
- Unless all the pages of this session are closed and then re-access a JSP or the servlet will create a new session.
Note: Note that the original session still exists, but the old SessionID still exist on the server, but no more clients carry it and then to the server check.
Destroyed:
There are only three ways to destroy a session:
1, call the Session.invalidate () method
2. Session expires (Timeout)
3. Server restart
Application object:
Common methods for application objects are as follows:
Page Object
PageContext Object
Common methods for PageContext objects are as follows:
Config object
Exception Object
Java meets html--jsp article: JSP built-in objects (bottom)