I am working on a project that involves implementing a fairly lengthy survey.
Currently, I am using session variables and requests that are read on a single JSP page to display the various questions. The problem I am running into shows up when the user uses the back button. I can give each "page" a modified URL so that the browser will display the HTML shown at the previous page (at this point it "looks correct"), but it doesn't actually reevaluate the Java code or restore/modify any of the session parameters correctly.
This results in unpredictable behavior when the user tries to do anything on the returned-to page, so I'd like to do something that would warn the user not to use the back button, and instead use the navigation controls that we implemented to go back to a previous survey page.
Use post to go from page to page and use the correct expires headers.
Joined: Jul 22, 2008
Eric Pascarello wrote:Use post to go from page to page and use the correct expires headers.
The way my code currently functions (correctly, minus the back button issue) is such:
A session variable is set (session.setAttribute("current", question_number)) that is read by the server to determine which question should be displayed.
The form is submitted, a second page processes it and determines the next question that should be displayed, and changes the "current" session attribute accordingly.
The second page redirects back to the first page, which displays a new question based on the new, modified "current" attribute.
I've tried setting the response fields to disable caching using:
but the session variable from the page the user goes back from is still set (ie, the "current" variable is +1 from where it should be after the back button is pressed). What I am guessing needs to happen is that session variable needs to expire after the original page is left, but I have no idea how to go about doing that.