How to prevent the JSESSIONID showing in the URL

Prakash picture Prakash · Jun 21, 2017 · Viewed 9.5k times · Source

I have created an login page in servlet using Google Datastore, it is working fine. but sometimes its showing the JSESSIONID in the URL.

How can I prevent the JSESSIONID sending through the URL? why its passing through the URL instead of request message?

Answer

VHS picture VHS · Jun 23, 2017

Add the following entry in your web.xml.

<session-config>
    <tracking-mode>COOKIE</tracking-mode>
</session-config>

This will instruct the container that the client supports cookies and hence there is no need to put the JSessionId in the URL.