Detailed explanation of sessions in JSP and analysis of its principles, jspsession
Session comprehension in JSP:
I. Session Introduction
In WEB development, the server can create a session object (session Object) for each user's browser. Note: a browser exclusively occupies a session object (by default ). Therefore, when you need to save user data, the server program can write user data to the session exclusively occupied by the user's browser. When you use the browser to access other programs, other programs can extract the user data from the user's session to serve the user.
Ii. Main differences between Session and Cookie
- Cookie is to write user data to the user's browser.
- Session technology writes user data to a session exclusively owned by the user.
- The Session object is created by the server. developers can call the getSession method of the request object to obtain the session object.
Iii. session implementation principle
How does a server implement a session to serve a user's browser? After a session is created on the server, the session ID will be sent back to the client in the form of a cookie. In this way, when the client's browser is disabled, the session ID will be carried when accessing the server, when the server finds that the client browser has brought the session id, it will use the corresponding session in the memory to serve it.
If you have any questions, please leave a message or go to the community on this site for discussion. Thank you for reading this article. Thank you for your support!