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.
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"
Your question made think of trying http://myservername/test1.jsp instead of http://localhost/test1.jsp or http://127.0.0.1/test1.jsp when browsing locally on the server. And in that case (using myservername) it failed. So it has to related to the domain. Also, I still don't see the cookies being created.
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.