This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

remove cache from java code in jsp

 
Sudarshan Reddy
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
i want to remove cache and not to allow the user to to go back when the user click on the back button in the browser

how can i achieve this from java code?
 
Steve Luke
Bartender
Posts: 4181
21
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the future, you should post JSP related questions to the JSP forum.

This question is very common over there in the JSP forum, you should see many answers if you search it, or use Google to search for JSP cache control. As a summary, there are several cache control headers you need to add to every response sent from your server that prevent caching the page.
 
Sudarshan Reddy
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i am not able to do this in internet Explorer where as it is not working file in Mozilla when i am accessing the application in different browsers

can you tell me the reason and help me

this is the code that i am using in my jsp

response.setDateHeader("max-age", 0);
response.setDateHeader("Expires", 0);
response.setIntHeader("max-age", 0);
response.setHeader("Cache-Control","no-cache");
response.addHeader("Cache-Control","no-store");
response.setHeader("Pragma", "no-cache");
response.setIntHeader ("Expires", -1);
response.addHeader("cache-Control", "private");
 
Steve Luke
Bartender
Posts: 4181
21
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which browser(s) is it not working in? What does it mean by 'not working?' Where are you putting that code? Have you done the search I suggested and read some of the several hundreds of threads on this subject?

You should also read this javaworld article on the subject. Make sure you also read the article referenced in the first paragraph of the provided link, since it provides the backbone for what the 'revisit' article is based on.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic