This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JSP and the fly likes I need to cache a page Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "I need to cache a page" Watch "I need to cache a page" New topic
Author

I need to cache a page

Timothy Sam
Ranch Hand

Joined: Sep 18, 2005
Posts: 746
Hi guys, I thought I needed to turn off caching on some of my pages. It was ok... Just now I discovered another problem, I need it on on some of my pages too! I have an application form and an error page where the application form forwards to the error page if something goes wrong

When I press the back button from errors.jsp, the values entered before are gone. This could make my users frustrated after filling up a very lengthy form. I need only to make the page expire if the user manages to go to the success page. Here are my HTML headers for both apply.jsp and errors.jsp..



and on some other pages...



Hope to hear from you soon guys! Thanks!

[ July 07, 2006: Message edited by: Timothy Sam ]
[ July 07, 2006: Message edited by: Bear Bibeault ]

SCJP 1.5
http://devpinoy.org/blogs/lamia/ - http://everypesocounts.com/
Travis Hein
Ranch Hand

Joined: Jun 06, 2006
Posts: 161
can you switch which of those meta tags gets rendered to the resulting jsp?

if you are not templating the site, then the required tags on each page.

if you use a common header include that contains them, pass a parameter to the include where


or, if you are using tiles and struts, i guess you could have a different top level tiles templates, one that includes a caching header, one that does not do caching tags.

I had a site where most pages did not need to include a big javascript and style sheet stuff, but this one needed a lot of javascript includes, so the header was a seperate tiles template that did the different html output as needed for javascript. i guess those meta tags to direct the browser on caching is similar. ?
[ July 09, 2006: Message edited by: Travis Hein ]

Error: Keyboard not attached. Press F1 to continue.
Timothy Sam
Ranch Hand

Joined: Sep 18, 2005
Posts: 746
Finally, a reply... Thank you very much. Actually, I didn't use Tiles because I didn't have time to learn them. But yes, the page is templated even the headers. I use similar headers like

cachetemplate.jsp
nocachetemplate.jsp

So basically, even without tiles the app is almost completely templated. I have a feeling that your suggestion will most likely work so I will put that on my app now and inform you of what happened.

Also, the page I want to cache is not an included page.

Thank you, thank you, thank you.
[ July 09, 2006: Message edited by: Timothy Sam ]
Timothy Sam
Ranch Hand

Joined: Sep 18, 2005
Posts: 746
Hmmmm... There's really something wrong.





this doesn't seem to do it. When I press the back button, the form values still disappears. Oh my... This is getting very frustrating... Please help...
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

Are you using HTTP 1.1 ? (there's an option in IE which should be turned on)

And maybe you should read about cache and meta tags here:
http://www.mnot.net/cache_docs/#META
In clear, try to use access HTTP headers directly, rather than rely on meta tags.
[ July 10, 2006: Message edited by: Satou kurinosuke ]

[My Blog]
All roads lead to JavaRanch
Timothy Sam
Ranch Hand

Joined: Sep 18, 2005
Posts: 746
Thanks... But.. Now I'm totally lost...


try to use access HTTP headers directly



How? Do you mean generate them through JSP/Servlet code?
Timothy Sam
Ranch Hand

Joined: Sep 18, 2005
Posts: 746
Ok, I think I solved the problem. I forgot to delete this line in my controller


response.setHeader("Cache-Control", "no-cache");


thank you very much guys. And I would probably be using Travis's suggestion this time!
 
 
subject: I need to cache a page
 
Similar Threads
how to prevent caching in IE 6
Caching is not working
What are these <meta> tags
After Logout still keeping session
Log out Functionality for my Web Application