how to clear browser cache programmatically in jsp?

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
}

%>

Tags:

Java

Jsp