title: Spring-security-3 browser back button issue
body: <p>I am just trying to learn Spring security 3. while running example of Spring security the back button takes me to previous page . I want to stop this. I just try to do that using spring security.but it was not resolved,Please help.Here is my code</p>
  
  <p>Security file</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;beans xmlns="http://www.springframework.org/schema/beans"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:security="http://www.springframework.org/schema/security"
      xmlns:mvc="http://www.springframework.org/schema/mvc"
      xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd
          http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.2.xsd
          http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"&gt;
  
      &lt;mvc:annotation-driven /&gt;
      &lt;mvc:interceptors&gt;
          &lt;mvc:interceptor&gt;
              &lt;mvc:mapping path="/**/*" /&gt;
              &lt;bean id="webContentInterceptor"
                  class="org.springframework.web.servlet.mvc.WebContentInterceptor"&gt;
                  &lt;property name="cacheSeconds" value="0" /&gt;
                  &lt;property name="useExpiresHeader" value="true" /&gt;
                  &lt;property name="useCacheControlHeader" value="true" /&gt;
                  &lt;property name="useCacheControlNoStore" value="true" /&gt;
              &lt;/bean&gt;
          &lt;/mvc:interceptor&gt;
      &lt;/mvc:interceptors&gt;
      &lt;security:user-service id="userServiceDAO"&gt;
          &lt;security:user name="mukesh" authorities="ROLE_USER"
              password="password" /&gt;
      &lt;/security:user-service&gt;
      &lt;security:authentication-manager&gt;
          &lt;security:authentication-provider
              user-service-ref="userServiceDAO" /&gt;
      &lt;/security:authentication-manager&gt;
      &lt;security:http auto-config="false"&gt;
          &lt;security:form-login login-page="/login"
              login-processing-url="/secure/sayHello" username-parameter="_username"
              password-parameter="_password" authentication-failure-url="/error"
              default-target-url="/secure/defaultTarget" /&gt;
          &lt;security:intercept-url pattern="/login"
              access="IS_AUTHENTICATED_ANONYMOUSLY" /&gt;
          &lt;security:intercept-url pattern="/secure/**"
              access="ROLE_USER" /&gt;
          &lt;security:logout logout-url="/logout" /&gt;
      &lt;/security:http&gt;
  &lt;/beans&gt;
  </code></pre>
  
  <p>FrontController-servlet.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;beans xmlns="http://www.springframework.org/schema/beans"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
      xmlns:c="http://www.springframework.org/schema/c" xmlns:mvc="http://www.springframework.org/schema/mvc"
      xmlns:context="http://www.springframework.org/schema/context"
      xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd
          http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
          http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd"&gt;
  
      &lt;mvc:annotation-driven /&gt;
      &lt;context:component-scan base-package="sample.security" /&gt;
      &lt;bean id="viewResolver"
          class="org.springframework.web.servlet.view.InternalResourceViewResolver"
          p:prefix="/WEB-INF/views/" p:suffix=".jsp"&gt;
      &lt;/bean&gt;
  &lt;/beans&gt;
  </code></pre>
  
  <p>MVC-controller</p>
  
  <pre><code>package sample.security.controller;
  
  
  import org.springframework.stereotype.Controller;
  import org.springframework.web.bind.annotation.RequestBody;
  import org.springframework.web.bind.annotation.RequestMapping;
  import org.springframework.web.bind.annotation.RequestMethod;
  
  @Controller
  public class SecureLoginController {
  
      @RequestMapping(value = {"/","/login"}, method = RequestMethod.GET)
      public String secureLogin() {
      return "login";
      }
      @RequestMapping(value = "/secure/defaultTarget", method = RequestMethod.GET)
      public String goToIndexPage(@RequestBody String body) {
          System.out.println("Request body is :"+ body);
          return "success";
      }
      @RequestMapping(value = {"/error"}, method = RequestMethod.GET)
      public String goToAgainLogin() {
          return "error";
      }
  
  }
  </code></pre>
  
  <p>login.jsp</p>
  
  <pre><code>&lt;%@ page language="java" contentType="text/html; charset=ISO-8859-1"
      pageEncoding="ISO-8859-1"%&gt;
  &lt;%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%&gt;
  &lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"&gt;
  &lt;title&gt;Login&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;h2&gt;Please Login&lt;/h2&gt;
      &lt;c:url value="secure/sayHello" var="loginURL" /&gt;
      &lt;form action="${loginURL}" method="post"&gt;
          &lt;label for="username"&gt;User Name&lt;/label&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;input
              type="text" size="30" name="_username" id="username"&gt;&lt;br /&gt;&lt;/br&gt; &lt;label
              for="password"&gt;Password&lt;/label&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;input
              type="password" size="30" name="_password" id="password"&gt;&lt;br /&gt;&lt;/br&gt; &lt;input
              type="submit" value="Submit"&gt;
      &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>success.jsp</p>
  
  <pre><code>&lt;%@ page language="java" contentType="text/html; charset=ISO-8859-1"
      pageEncoding="ISO-8859-1"%&gt;
  &lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"&gt;
  &lt;title&gt;success&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;h2&gt;I got success&lt;/h2&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>error.jsp</p>
  
  <pre><code>&lt;%@ page language="java" contentType="text/html; charset=ISO-8859-1"
      pageEncoding="ISO-8859-1"%&gt;
  &lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"&gt;
  &lt;title&gt;Error page&lt;/title&gt;
  &lt;%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;h2&gt;Invalid use name Or password&lt;/h2&gt;
      &lt;c:url value="secure/sayHello" var="loginURL" /&gt;
      &lt;form action="${loginURL}" method="post"&gt;
          &lt;label for="username"&gt;User Name&lt;/label&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;input
              type="text" size="30" name="_username" id="username"&gt;&lt;br /&gt;&lt;/br&gt;
          &lt;label for="password"&gt;Password&lt;/label&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;input
              type="password" size="30" name="_password" id="password"&gt;&lt;br /&gt;&lt;/br&gt;
          &lt;input type="submit" value="Submit"&gt;
      &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>web.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
      xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
      version="3.0"&gt;
      &lt;display-name&gt;Archetype Created Web Application&lt;/display-name&gt;
      &lt;context-param&gt;
          &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
          &lt;param-value&gt;
      /WEB-INF/configuration/CustomSecurity.xml
      &lt;/param-value&gt;
      &lt;/context-param&gt;
      &lt;filter&gt;
          &lt;filter-name&gt;springSecurityFilterChain&lt;/filter-name&gt;
          &lt;filter-class&gt;org.springframework.web.filter.DelegatingFilterProxy&lt;/filter-class&gt;
      &lt;/filter&gt;
      &lt;filter-mapping&gt;
          &lt;filter-name&gt;springSecurityFilterChain&lt;/filter-name&gt;
          &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
      &lt;/filter-mapping&gt;
      &lt;servlet&gt;
          &lt;servlet-name&gt;FrontController&lt;/servlet-name&gt;
          &lt;servlet-class&gt;org.springframework.web.servlet.DispatcherServlet&lt;/servlet-class&gt;
          &lt;init-param&gt;
              &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
              &lt;param-value&gt;/WEB-INF/configuration/FrontController-servlet.xml&lt;/param-value&gt;
          &lt;/init-param&gt;
          &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
      &lt;/servlet&gt;
      &lt;servlet-mapping&gt;
          &lt;servlet-name&gt;FrontController&lt;/servlet-name&gt;
          &lt;url-pattern&gt;/&lt;/url-pattern&gt;
      &lt;/servlet-mapping&gt;
      &lt;listener&gt;
          &lt;listener-class&gt;org.springframework.web.context.ContextLoaderListener&lt;/listener-class&gt;
      &lt;/listener&gt;
  &lt;/web-app&gt;
  </code></pre>
  
  <p>please provide me a Solution to rectify this issue.Thanks in advance</p>