How to generate jsessionid
Jsessionid is just Tomcat’s name for sessionid, which is actually sessionid; it may not be called jsessionid in other containers.
First of all, let’s talk about the creation of session objects in web development and the operating mechanism of generating and returning sessionId to the client.
The session object is accessed for the first time by the client. At the same time, create a new session object. At the same time, a sessionId is generated, and in this response, the sessionId is returned to the client browser memory in the form of a response message or sent back to the client in the form of rewriting the URL to maintain the entire Session, as long as the session object on the server side is not destroyed, when request.getSession() is called in the future, the session object generated by the server side will be directly retrieved based on the client's sessionId and returned. It will not be created again unless the sessionId is not retrieved. session object.
The following is tested under IE, because a BUG of IE6.0 is that even when all cookies are blocked, IE's privacy settings will still use session cookies to save the sessionId. Therefore, the following are all based on session cookies. discussed.
(1) When the server is not closed and within the session object destruction time, when the client requests the server-side servlet or jsp again, the sessionId generated in the first request will be appended. In the request header and sent to the server, after receiving the sessionId, the server will search for the session object corresponding to the server based on this sessionId (this process is transparent) and directly return the session object. At this time, it will not re-create a session object. New session object.
(2) When the server is closed (the previously generated session object will also die), or after the session object has passed its destruction time, the browser window will not close and will be browsed in this session. When the server window requests the servlet and jsp on the server side again, the sessionId (sessionId generated when the server is closed or the session is destroyed) will also be sent to the server side. The server will find its corresponding session object based on the sessionId, but at this time the session object No longer exists. At this time, a new session object will be regenerated, a new sessionId will be generated, and the newly generated sessionId will also be sent to the browser memory in the form of a response message.
(3) . When the server is not closed and the session object is within its destruction time, when a jsp page is requested back to the client, the browser window is closed. At this time, the sessionId in its memory is also destroyed, and the server is requested again. When using servlet or jsp, a sessionId will be regenerated to the client browser and stored in the browsing memory.
To summarize, the workflow of jsessionid can be simply represented by the following figure:
Related learning recommendations: java basics
The above is the detailed content of How to generate jsessionid. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Troubleshooting and solutions to the company's security software that causes some applications to not function properly. Many companies will deploy security software in order to ensure internal network security. ...

Field mapping processing in system docking often encounters a difficult problem when performing system docking: how to effectively map the interface fields of system A...

When using MyBatis-Plus or other ORM frameworks for database operations, it is often necessary to construct query conditions based on the attribute name of the entity class. If you manually every time...

Solutions to convert names to numbers to implement sorting In many application scenarios, users may need to sort in groups, especially in one...

Start Spring using IntelliJIDEAUltimate version...

Conversion of Java Objects and Arrays: In-depth discussion of the risks and correct methods of cast type conversion Many Java beginners will encounter the conversion of an object into an array...

Detailed explanation of the design of SKU and SPU tables on e-commerce platforms This article will discuss the database design issues of SKU and SPU in e-commerce platforms, especially how to deal with user-defined sales...

When using TKMyBatis for database queries, how to gracefully get entity class variable names to build query conditions is a common problem. This article will pin...
