How do I prevent the output of my JSP or Servlet pages from being cached by the browser?

Showing Answers 1 - 2 of 2 Answers

Suresh Lakkavajhala

  • Jun 12th, 2006
 

Execute the following scriptlet at the beginning of your JSP pages to prevent them from being cached at the browser:

<%

response.setHeader("Pragma","no-cache"); //HTTP 1.0
response.setHeader("Cache-Control","no-store"); //HTTP 1.1


%>

Sureshlvn

  • Jun 12th, 2006
 

Appropriate HTTP header attributes have to be set to prevent the dynamic content output by the JSP page from being cached by the browser. The following jsp code has to be included at the beginning of your JSP pages to prevent caching :<%response.setHeader("Pragma","no-cache"); //HTTP 1.0response.setHeader("Cache-Control","no-store"); //HTTP 1.1%>

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions