In my web application there is some problem due to browser cache.
How to clear the browser cache when loading my jsp page?
How can i include clear cache code in jsp page?
You can do this way in your JSP to prevent from caching
,not able to clear the cache programatically:
<% response.setHeader("Cache-Control","no-cache"); //HTTP 1.1
response.setHeader("Pragma","no-cache"); //HTTP 1.0
response.setDateHeader ("Expires", 0); //prevents caching at the proxy server
%>
<%
response.setHeader("Cache-Control", "no-cache");
response.setHeader("Cache-Control", "no-store");
response.setHeader("Pragma", "no-cache");
response.setDateHeader("Expires", 0);
%>
work perfect in jsp and remember to check session
<%
User u = (User) request.getSession().getAttribute("user");
if (u != null ) {
//show page
}else{
// redirect to login page
}
%>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With