I am having this weird problem with Tomcat v.5.5.20 . I have a simple JSP that sets a session attribute (session key) and has a form with a couple of text input fields and a submit button. The action of the form is another JSP and the method is post. The other JSP reads the session attribute. If I browse these JSPs locally I have no problems reading the session attribute in the second JSP. But if I do it from another computer, the seconds JSP gets a null value for the attribute. It looks like the session has been lost. Any ideas of what I am doing wrong or if there is any setting missing in Tomcat? Here's the code for the JSPs.
[ August 22, 2007: Message edited by: Fernando Margueirat ]
[ August 22, 2007: Message edited by: Fernando Margueirat ] [ August 23, 2007: Message edited by: Fernando Margueirat ]
Cookies are enabled in both browsers. And if I switch the computers and run Tomcat from the "remote" computer the problem persist. Locally (the one that use to be remote) the page loads ok, but remotely it fails. BTW I forgot to mention that I am using Tomcat v. 5.5.20. I'll add that to the original post.
Here some things to do to check to see what is happening.
Print out the hex code of the session for the remote client in both JSPs. For both requests the hex code should be the exact same. (You can often see the hex code of an object by doing a toString().
Check the physical cookie file on the remote client. Really check to see if the jsessionid is being set in that file.
There was something else, but I can't remember it right now.
Joined: Jun 07, 2004
When I print the session.toString() when running locally I get the same values in both JSPs but when I run it from a remote computer I get to different values. This confirms that Tomcat is creating a new session when moving to test2.jsp.
I would love to hear what was the other thing to check if you remember.
Yep, you are wrong. As per the Servlet/JSP API, the default method for session tracking depends on cookies. Therefore client browser cookie handling is important. Note that normally session tracking only works within the same "web application"
Never mind guys. The problem has f...ing Windows Internet Explorer. Even though I have cookies enabled and my web server added to the Local Intranet with Low security, it is still not creating the cookies.
I've tried it in Firefox without any problems. GRRRRRRRRRRRRRRRRRRRRR.