File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSP and the fly likes Cache Control Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Cache Control" Watch "Cache Control" New topic

Cache Control

Bunty Paul

Joined: Jun 26, 2006
Posts: 28

I have few jsp pages and in order control the cache i set the header info to "no-cache". It's working fine but my problem now is i am repeating this "header" in every jsp page.

response.setHeader("Pragma", "no-cache");
response.setHeader("Pragma", "no-store");
response.setHeader("Cache-Control", "no-cache");
response.setHeader("Cache-Control", "no-store");
response.setDateHeader ("Expires", 0);

IS there any solution so that it is specified globally or can i specify it in web.xml.

Server used : jboss 4.0.3SP1
Browser : IE 6.0

Ben Souther

Joined: Dec 11, 2004
Posts: 13410

No but you could create either a custom tag or an include that will reduce the code to one line per page.

Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Ben Souther

Joined: Dec 11, 2004
Posts: 13410

You could do this with a filter too.
I agree. Here's the link:
subject: Cache Control
jQuery in Action, 3rd edition