tags:

views:

443

answers:

1

Hello,

it seems that the Parameter-Name in the GET request, that represents the SessionID (like jsessionid=XXXXXXXXXXXXXXXXXXXXXXXXXX in Tomcat) is not standardized in the servlet-spec? How can I get the (Servelt Container Specific) name of the SessionID? (At least in Websphere there seems to be the possibilty to change the name of the SessionID-Parameter-Name)

=> The underlaying problem is, I need to encode a URL in a servlet ALWYAS with the session ID. But it seems that the "response.encodeURL()" Method only does this if Cookies are disabled (=>therefor using URL-Rewriting with the sessionID in the URL).

What would be an alternative to always encode a URL with a session ID in a servlet? As the first question implies I wanted to build the sessionid on my own but I therefore need the sessionID-Parameter Name that however seems not be be standardized, so I somehow need to get the Parameter-Name from somewhere...)

UPDATE: The intention is to keep the SessionManagement Functionality provided by the Servlet-Container and not turn it off completely. I need to pass a Callback URL to a third party system that I want to always contain the SessionURL. So I only want to encode this single URL always with the sessionID to minimize any security issues...

Thank you very much Jan

+2  A: 

The jsessionid isn't actually a request parameter, it's encoded on to the URL itself, and then decoded and removed by the container before it gets as far as your controller. The value of jsessionid itself can be retrieved from HttpSession.getId().

If you want to stop Tomcat from using cookies, then you can provide a tomcat-specific context.xml file under WEB-INF, containing something like this:

<Context cookies="false" path="/path/to/my/webapp">
</Context>

This will disable all cookies for that webapp, and tomcat should then automatically encode all session IDs on to the URL instead.

skaffman
+1 for the hint to anyway disable cookies from the server side on.
BalusC
Hello skaffman, thanks for your answer. Your answer providers some interesting information I did not know but doesnt solve the problem. I want to keep the Session-Management as provided by the Servlet-Container but however "force" the container to encode a specific URL I will pass to a thirdparty system. For "security reasons" I want to make shure the callback URL does not rely on cookies rather always contains the sessionID that I have set in the Callback URL. As described above I therefore need to find a way to always encode my URL with the session Id. thanks jan.
jan
The Servlet API provides no way to force the container to do this. You'll have to live with a proprietary mechanism for each container.
skaffman
hello skaffman, thanks, it seems its not really possible what I am trying to do...
jan