This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes JSP and the fly likes JSP Caching issue Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Java » JSP
Bookmark "JSP Caching issue" Watch "JSP Caching issue" New topic

JSP Caching issue

Sandeep saahil

Joined: Jan 09, 2008
Posts: 12
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.

Dreams are not what you get when you sleep...It is something which don't let you sleep
Srikanth Nutigattu
Ranch Hand

Joined: Oct 30, 2007
Posts: 114
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

Joined: Jan 09, 2008
Posts: 12
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.

Srikanth Nutigattu
Ranch Hand

Joined: Oct 30, 2007
Posts: 114
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

Joined: Jan 10, 2002
Posts: 63208

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.

JavaRanch sheriff

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Satya Maheshwari
Ranch Hand

Joined: Jan 01, 2007
Posts: 368
@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?

Thanks and Regards
Srikanth Nutigattu
Ranch Hand

Joined: Oct 30, 2007
Posts: 114
Please use real words...

Oops!! My bad, missed that somehow.


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.

[ December 02, 2008: Message edited by: Srikanth Nutigattu ]
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link:
subject: JSP Caching issue
It's not a secret anymore!