Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

how to remove jsessionid from embedded URLs

843842Feb 27 2008 — edited Sep 9 2008
hi,

i have an application running on tomcat. when the page loads for the first time all of the links on my page have a jsessionid trailing after the URL as follows:

/main/test.js;jsessionid={random sequence for the id}

if i simply do a refresh, the jsessionid is removed from all of the links, so it becomes what it is supposed to be:

/main/test.js

- Is there a way I can stop this behavior of jsessionid appearing in the url?

Thanks!

Comments

843842
I have noticed the same behavior, and no, I am afraid I not smart enough to answer why this behavior occurs. I do know that the does not happen when you modify your browser settings to 'block all cookies'.

I would assume that it stops displaying the jsessionid in the url because the servlet is actually pulling the information it needs from a cookie.

I would really appreciate someone wih a lot more knowledge in the area to respond to this thread.
843842
Hi,

This a feature used by the server to identify a session with browsers that does not return cookies. It is known as url rewriting.
So, if the browser has cookie enabled, you'll not see this pararmeter.
843842
I agree that is what should happen and normally does; however, I am seeing some thing I did not expect in the following scenario.

This is what I did to test:

I completely emptied the Temporary Internet Files folder (no cookies, no css, no js, nothing in the folder).
I make sure cookies ARE NOT being blocked.
I open my web browser with the web application's home page (home.jspx) set as my IE default home.
When the home.jspx loads, several files are placed in the Temporary Internet Files folder; a cookie, a css, a js and some gifs. All of these files, except the cookie, have the jsessionid appended to the file name.
I then click a link within my web application which promptly loads one of my other pages with in the application.
In the Temporary Internet Files folder, I now see twice the number of files; however, these new files are duplicates of the previous files except these new files DO NOT have the jsessionid appended to them.
As I continue to use my application, the 'Last Accessed' date/time is updated on the files with no jsessionid appended to them. (this behavior I expect since the application is now using the cookie)

What I do not expect is that URL Rewriting is occuring on load whether the cookie is there or not. After the initial page is loaded, URL Rewriting is not being used; the cookie is being updated accordingly.

Now, if I open up 5 sessions, I will see 6 sets of files. 5 sets with 5 distinctly diferent jsessionids appended, and 1 set with no jsessionid. Again, after each session is created, all 5 browsers (sessions) start using the same files (the ones with out jsessionid appended to them), and the ones with the jsessionid are ignored.

Is this normal behavior? I would expect it to never append the jsessionid to any files or URL when cookies are not blocked whether the cookie is present or not, especially when it is present.

BTW. My application is JSF and it is running on Oracle Application Server 10gR3 (oc4j). Does this change the behavior?

Also, I posted a thread yesterday about my issue:
http://forums.sun.com/thread.jspa?threadID=5322628&messageID=10380089#10380089
843842
I saw the other thread and it was helpful. Thanks a lot.
1 - 4
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Oct 7 2008
Added on Feb 27 2008
4 comments
1,009 views