We keep our JSPs from caching by including the following line at the top of each one.
<% response.setHeader("Expires", "Tues, 01 Jan 1980 00:00:00 GMT"); %> This means that every time somebody enters the URL it will call the server instead of reading the file out of the browser cache. It does not prevent the user from hitting the back button and seeing the same page without hitting the server again. I am not sure that you can force the browser to hit the server again when the user hits the back button. -----Original Message----- From: RESTREPO, ALEXANDER G [Non-Pharmacia/1000] [mailto:[EMAIL PROTECTED]] Sent: Thursday, October 04, 2001 3:07 PM To: JRun-Talk Subject: How do you prevent JSP's from Caching Hi: I want to expire a JSP in order to prevent a user from hitting the back button and viewing the information on the previous page. Here is an example of a JSP I wrote to test this and so far I have not been able to prevent caching. Could anyone provide me with some recommendations? Many Thaks: Alex Restrepo Monsanto -------cut here-------------------- <%@ page import="java.util.*" %> <% response.setHeader("Cache-Control", "no-cache"); response.setHeader("Pragma", "no-cache"); response.setDateHeader("Expires", -1); %> <HTML> <HEAD> </HEAD> <BODY> <% out.println("Request Headers"); out.println(""); Enumeration enum = request.getHeaderNames(); while(enum.hasMoreElements()) { String name = (String)enum.nextElement(); String value = request.getHeader(name); if ( value != null) { out.println(name + ": " + value + "<P>"); } } %> This is a test <P> <P> <A HREF="http://www.ibm.com"><FONT COLOR=red >IBM</FONT></A> <P> <P> <%=System.currentTimeMillis()%> <p> This session will expire in <% out.println( session.getMaxInactiveInterval() ); %> seconds. <p> </BODY> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Get the mailserver that powers this list at http://www.coolfusion.com Archives: http://www.mail-archive.com/jrun-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists