It's not a secret anymore!*
The moose likes Struts and the fly likes 64 bit jsessionid in Struts Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "64 bit jsessionid in Struts" Watch "64 bit jsessionid in Struts" New topic
Author

64 bit jsessionid in Struts

Yogendra Joshi
Ranch Hand

Joined: Apr 04, 2006
Posts: 213
Hello Friends ,

The day yesterday i was using the application made by me in Struts. Whenevr i login , Normally it alwayz showed 32 bit session id which is being generated by the Server...

However , Today when i logged in it had shown me 64bit jsessionid. I wanted to know what exactly is this and also wanted to know that i have not used url rewriting then too how automatically does it append jsessionid to the end of URL ?

Thanks in Advance.
Yogendra Joshi


Meri Zindagi Hain Tab Tak.. Jab Tak Tera Sahara.... Har Taraf Tu Hi Tu Hain SAI Tera Hi Hain Nazara.....
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
The JSessionId isn't generated by Struts. It's generated by your application server. Generally, an application server will use cookies to determine which HttpSession a user belongs to.

Cookies are not 100% reliable, though, because they can be turned off on the browser. To cover this possibility, the application server can append the session id with every link and use it to determine the session.

This is called URL Rewriting, and it's done by passing the URL to the encodeURL method on the HttpServletResponse object. This causes the application server to append the JsessionId to the URL. If you're using Struts tags exclusively, you don't have to worry about URL rewriting because struts calls the encodeURL method for every link and action. However, if cookies are enabled on your browser, it's the cookie and not the JsessionId that's being used to attach you to a session.


Merrill
Consultant, Sima Solutions
Yogendra Joshi
Ranch Hand

Joined: Apr 04, 2006
Posts: 213
Hey Merrill Thanks for the reply.

I understand that the URL rewriting process is done using the servlet container and not by Struts, It was only that i have worked on Struts for the first time and noticed 64bit i.e 64 characters after jsessionid as in here ... http://localhost:8000/Yogendra/abc.jsp?jsessionid=sadasdasdaasdewfvfgdff....

So my question was why did it generate 64 chars in place of 32 chars by default which i alwayz have seen..

Waiting for your kind suggestions again.

Thanks
Yogendra Joshi.
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
Since the Application Server is responsible for the generation of the JSessionId, the answer as to why it is using 64 characters lies in the documentation of whatever application server you're using. The fact that you're using Struts has nothing to do with it.
 
 
subject: 64 bit jsessionid in Struts