Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

When to use jsessionid rewriting in url?


Asked by Reuben Enriquez on Dec 14, 2021 FAQ



If the client comes back with no cookie, then the server needs to continue to use jsessionid rewriting in url. But nowdays it's really hard to imagine clients/users without cookie support.
Subsequently,
This isn't a bug, it's by design. When a new session is created, the server isn't sure if the client supports cookies or not, and so it generates a cookie as well as the jsessionid on the URL.
Thereof, If the cookies are disabled at client side and we are using URL rewriting then this method uses the jsessionid value from the request URL to find the corresponding session. JSESSIONID cookie is used for session tracking, so we should not use it for our application purposes to avoid any session related issues.
In fact,
When a new session is created, the server isn't sure if the client supports cookies or not, and so it generates a cookie as well as the jsessionid on the URL. When the client comes back the second time, and presents the cookie, the server knows the jsessionid isn't necessary, and drops it for the rest of the session.
Indeed,
When a web crawler tries to index your website, it will send a request without a session identifier (naturally). Your servlet container will reply with a page containing rewritten URLs with a jsessionidpath parameter. It will also send the session cookie, but web crawlers ignore cookies.