We just ran across the problem recently and handled it on the client side. 
 You can create a form on the page with whatever hidden fields you want, 
then use JavaScript to make the form submit to your desired URL using a 
post method.  That way, it doesn't matter if the end user has their 
browser set to read from cache.  Total hack, but it works well with 
hrefs...

>>> Jeff Ramin <[EMAIL PROTECTED]> 10/5/01 1:21:54 AM >>>
Mark Phelps wrote:
> 
> 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.

Yes, this should cause the browser to perform as desired.  It
won't necessarily stop proxy servers from returning an old
page.

> 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.

I'm not aware of a way to do that either, short of spawning a new
browser window that has the back button removed.  I have seen that
done, but it probably makes users angry.


> 
> -----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/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to