• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JSP Caching issue

 
Sandeep saahil
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Techies,
I have a weird requirement(can't help it as decisions are not in my hand). In My JSP(register.jsp), there are multiple fields like text boxes, radio buttons etc and a terms and conditions link. The "terms and conditions" page has to open up in same window(This is done so that user journey is not affected). If user clicks browser's back button from terms and conditions page, register page should show up with all the fields that user might have entered. So far so gud.

But Problem is register.jsp cant be cached. So I included all the no-cache meta tags. It is working fine with no caching in place. But the problem is that if user clicks the back button from terms and conditions page, the register.jsp fields are cleared(as expected). I want that the page shouldn't be cached but if the user comes from browser back button, these fields should not be cleared.

I know it is weird that i want and at the same time I dont want caching. But I can't help it. Is there any 'accepted' way for doing this?

Thanks in advance.
 
Srikanth Nutigattu
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use a java bean instance to store the values, when the user clicks the "Terms and conditions" link, store the form values in the bean and when he clicks "back to form" populate the values from the bean. Isn't that simple?
 
Sandeep saahil
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Srikanth for your prompt reply. If I understand your solution properly, then the bean should be populated on clicking the link. How is it possible? We have javascript disabled. so probably linking the link to some action to do so.
Also, I m talking about browser's back button. Is it possible there? Please guide.

regards.
 
Srikanth Nutigattu
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
so probably linking the link to some action to do so.

yes thatz correct.

I don't know how to handle the back button scenerio...
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65126
92
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please use real words when posting to the forums. Abbreviations such as "thatz" in place of "that's" only serve to make your posts more difficult to read and less likely to generate useful responses.

Please read this for more information.

thanks,
bear
JavaRanch sheriff
 
Satya Maheshwari
Ranch Hand
Posts: 368
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@Sandeep saahil
I guess the proper way of doing this is to have 'Terms and conditions' opening in a separate pop-up with an 'Agree'/'Disagree' button. But as you have stated, that is not an option.

Since you are not caching the page contents, it means the browser back button is actually fetching the page from the server. So you can consider keeping the form values entered on the page in HttpSession. Everytime you render the page, you should check if values are present in HttpSession for it, and if they are, you can populate those. Will it work for you?
 
Srikanth Nutigattu
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@Bear
Please use real words...


Oops!! My bad, missed that somehow.

Thanks!!

I think if the page is fetched from the browser on clicking of back button, (As stated) then you can go ahead with the bean stored in the 'session' scope as discussed.

Cheers!!
[ December 02, 2008: Message edited by: Srikanth Nutigattu ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic