How to prevent going back to the previous page by hitting the Back button ?

In the html code I generate from my servlet, I have the following :
<Html>
<Head>
<Title>Cox Part Time Benefit App Login Page</Title>
<Meta http-equiv="Pragma" content="no-cache">
<!-- Pragma content set to no-cache tells the browser not to cache the page. This may or may not work in IE -->
<Meta http-equiv="expires" content="0">
<!-- Setting the page to expire at 0 means the page is immediately expired. Any vales less then one will
set the page to expire some time in past and not be cached. This may not work with Navigator -->
<Meta http-equiv="Cache-Control" content="no-cache">
<!-- This directive indicates cached information should not be used and instead requests should be forwarded
to the origin server. This directive has the same semantics as the PRAGMA:NO-CACHE -->
</Head>
I hope it can prevent user from going back to the previous page by hitting the Back button on the browser, but it doesn't, what's the right way to do it ?
Frank

I think I'm half way now, but something is missing. I have the following filter :
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.util.*;
public class ResponseHeaderFilter implements Filter
  FilterConfig fc;
  public void doFilter(ServletRequest req,ServletResponse res,FilterChain chain) throws IOException,ServletException
    HttpServletResponse response=(HttpServletResponse)res;
    for (Enumeration e=fc.getInitParameterNames();e.hasMoreElements();)        // Set the provided HTTP response parameters
      String headerName=(String)e.nextElement();
      response.addHeader(headerName,fc.getInitParameter(headerName));
    chain.doFilter(req,response);                                              // Pass the request/response on
  public void init(FilterConfig filterConfig)
    this.fc=filterConfig;
  public void destroy()
    this.fc=null;
}And in my web.xml, I have something like this :
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
  <servlet>
  </servlet>
  <servlet-mapping>
  </servlet-mapping>
  <session-config>
  </session-config>
  <welcome-file-list>
  </welcome-file-list>
<resource-ref>
</resource-ref>
<filter>
  <filter-name>ResponseHeaderFilter</filter-name>
  <filter-class>ResponseHeaderFilter</filter-class>
  <init-param>
    <param-name>Cache-Control</param-name>
    <param-value>private,no-cache,no-store</param-value>
   </init-param>
  <init-param>
    <param-name>Pragma</param-name>
    <param-value>no-cache</param-value>
   </init-param>
  <init-param>
    <param-name>expires</param-name>
    <param-value>0</param-value>
   </init-param>
</filter>
</web-app>I rebuilt the project and ran it, and yet, I can still hit the "Back" button and get to previous page, what am I missing ? Is what I've done in the web.xml file enough to set it up, or do I need to call ResponseHeaderFilter somewhere in my servlet in order to use it ?
Frank

Similar Messages

Maybe you are looking for