• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Dealing with back buttons

 
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey all-

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.

Does anyone have any idea how this sort of thing could be implemented, preferably with no or minimal JavaScript?

Thanks a lot for any help/suggestions.
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Use post to go from page to page and use the correct expires headers.

Eric
 
Sam Gardner
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Eric Pascarello wrote:Use post to go from page to page and use the correct expires headers.

Eric



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.

Do you have any thoughts or a link to a tutorial so that I can do this correctly without resorting to JavaScript hacks?
 
Eric Pascarello
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
name='cache-control' value='no-cache, no-store, must-revalidate'

 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic