Session plays an important role in most web applications. Since HTTP protocol is stateless, the Server identifies the user via the JSESSIONID cookie created at the user end. Most users don't disable cookies in their browser. But when a user has disabled cookies in his browser, URL rewriting is the only by which we can
exchange session Id between client and the server.URL rewriting is simple.
In URL rewriting technique we can see that the jsessionid will be appended to the hyperlinks in the web page.
In
JSP use the c:url tag.
<a href=”<c:url value=’/Example.do’ />”>Click here</a>
IN Servlets use the encodeUrl()
Use the encodeURL() function of response object.
Example:
out.println(“<a href=\”” + response.encodeURL(“/Example.do”) + “\”>click here</a>”);
Final sample URL : (look at the jsessionid appended to the URL)
http://www.tester.com/Example.do;jsessionid=0CCB5C8DE517