I have two JSPs and one Class file that is serializable (I call that my "bean") that I use to store values for JSP #1 and JSP#2. JSP #1 sets a value in my "bean" using a setter method. It does not matter that the value is char, string, or boolean. The user can click on a hyperlink that passes a value back to JSP #1 - and, as a result, I reset the value using the setter method. So far, so good. Now, the user clicks the hyperlink again, so I pass a different value back to JSP #1, and again, I reset the value in the bean. We do this two more times before the user hits the update button and I go to JSP #2 - BUT the value in the bean is the PREVIOUS value - not the one I just set.
In short: this is the sequence:
JSP#1 value = "current" JSP#1 value = "next" JSP#1 value = "current" JSP#1 value= "next"
User presses UPDATE to go to JSP #2. The value JSP#2 picks up is "current". If I hit the "refresh" button before the UPDATE button, the value is CORRECT! This is driving me nuts!
Here is my bean setting in JSP#1 and JSP#2:
<jsp:useBean id="mySession" class="SessionBean" scope="session" /> Thanks for any assistance.
Bear: It was a caching problem - not at the webserver, but at the browser. I didn't realize that browsers cache .jsp pages also. I guess a good practice may be to add a unique value on the post parameter after the URL? Thanks. Karen
Joined: Sep 30, 2003
I found the tag that will prevent browser caching: <META HTTP-EQUIV="Pragma" CONTENT="no-cache"> <META HTTP-EQUIV="Expires" CONTENT="-1"> I added it and this fixed by session variable problem.
from a browsers view there is no difference between a .html .jsp .php .cgi or anything else, they are all just HTML files. once you've finished active development you might want to remove those restrictions on caching, because there are good reasons for browsers to make a cache. personally i just turn off caching within my own browser to avoid problems
Kim Jong II (North Korea's Dear Leader) said:Nuclear weapons don't kill people, people kill people.
once you've finished active development you might want to remove those restrictions on caching
Not if your pages have active content. You don't want stale content being plucked out of the cache. Also, methinks its a bad idea to deploy with a different configuration than you developed and tested with. bear
Joined: Oct 04, 2003
hence the might a lot of people are on slow connections (including me!) and so unless it really is second specific data it's wise to allow (at least some) caching