• Post Reply Bookmark Topic Watch Topic
  • New Topic

Browser back button and servlet state

 
Mark McKay
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm writing something where if the user clicks on the browser's back button and makes a new selection from an older page, my servlet should react to the state at the time that page was generated and not any clicks that the user made later on.

The easiest way I can think of to do this is to completely ignore the session and to store the state on each web page as it's generated. I'd have to POST this state each time the user clicked a link, but the data block I'd need shouldn't be too big. My server would also take a hit generating and parsing this data block for each page.

If there's an easier way to do this, please let me know.
 
Lalit Mehra
Ranch Hand
Posts: 384
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hey hi,

please clarify the first paragraph a little more ...

thanks
 
Mark McKay
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I were writing a shopping cart and the user put an item in their cart and pressed the back button a few times and then did something else, the item they selected would still be in their cart (as stored in the session object).

I don't want that. My website works more like a decision tree. If the user goes down one path and then decides to back up and try something else, the state should backup too. One way to do this is to ignore the session and put the relevant info on every generated web page. I'm wondering, though, if there may be a better way that would require less processing.
 
Lalit Mehra
Ranch Hand
Posts: 384
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you probably should not save such data in the sessions object because as you mentioned your application works on the decision tree principle ... so you better should judge the output of every consecutive page from the inputs of the immediate previous page only ... don't you think so ...

 
Mark McKay
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, that's what I said in both of my previous posts.

However, as this seems like it would be a common problem and there is room to improve efficiency, I'm posting here to see if anyone may know a better solution.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!