title: How to get GET parameter in Spring Security?
body: <p>I'm using Spring Security 3.1 and I wanted to obtain the parameter coming from the URL BEFORE the user logs in. So I'm expecting the user that´s accessing my login page to send me a redir parameter (containing the URL he wants go to after he´s authenticated). When I request the page, not when I try to submit the form to log in.</p>
  
  <p>For example: localhost/myApp?redir=my.app.com/custom</p>
  
  <p>How can I get the redir param from URL?  </p>
  
  <p>I've tried several things, including overriding SimpleUrlAuthenticationSuccessHandler and calling request.getParameter("redir") but it returns null. I've also tried implementing my own filter UsernamePasswordAuthenticationFilter and calling getParameter() on attemptAuthentication, but returns null.</p>
  
  <p>UPDATE for additional info: 
  My login page is fairly simple, basically: A form calling /j_spring_security_check via POST  method (with j_username and j_password parameters). <br/> <br/>
  My authentication provider implements AuthenticationManager, so the Authentication object is returned with the authorization list, user, password after the user has authenticated. <br/><br/>
  I also implemented SimpleUrlAuthenticationSuccessHandler and the method onAuthenticationSuccess() would check his permissions and if authenticated and permissioned, the user would be redirected to the page he informed on URL (now, when I try to call request.getParemeter("redir") on this method, I get null.</p>
  
  <pre><code>public class GetURLFilter extends UsernamePasswordAuthenticationFilter{
  @Override
  public Authentication attemptAuthentication(HttpServletRequest request, HttpServletResponse response)
          throws AuthenticationException {
  
      String paginaRedirecionar = request.getParameter("redir");
      request.getSession().setAttribute("redirecionamento", paginaRedirecionar);
  
      return super.attemptAuthentication(request, response);
  }
  }
  
  &lt;bean id="authenticationFilter"
      class="com.uolinc.adm.security.GetURLFilter"
      p:authenticationManager-ref="radiusAuthenticationManager"
      p:authenticationFailureHandler-ref="radiusAuthenticationFailureHandler"
      p:authenticationSuccessHandler-ref="radiusAuthenticationSuccessHandler" /&gt;
  
  &lt;security:http auto-config="false"
      use-expressions="true"
      access-denied-page="/auth/denied" entry-point-ref="authenticationEntryPoint"
      disable-url-rewriting="true"
      access-decision-manager-ref="accessDecisionManager"&gt;
  
      &lt;security:logout logout-url="/auth/logout" logout-success-url="/auth/login" /&gt;
  
      &lt;security:custom-filter position="FORM_LOGIN_FILTER" ref="authenticationFilter" /&gt;
  &lt;/security:http&gt;
  </code></pre>
  
  <p>Thank you</p>