Results 1 to 2 of 2

Thread: registration and login buttons in same form (JSP)

Hybrid View

  1. #1
    Join Date
    Feb 2013
    Posts
    1

    Question registration and login buttons in same form (JSP)

    Is there any way to use two submit buttons in same form, one using the url "j_spring_security_check" and the other one calling a controller method?

    thanks in advance for your help!

  2. #2
    Join Date
    Jan 2008
    Posts
    1,826

    Default

    You would need to override the requiresAuthentication method to return true when an http parameter is present and matches the URL:

    Code:
    protected boolean requiresAuthentication(HttpServletRequest request, HttpServletResponse response) {
        return request.getParameter("login") != null && 
                super.requiresAuthentication(request,response);
    }
    Then your controller could act upon the same URL when the parameter registration is non null.

    Code:
    @RequestMapping(value="/j_spring_security_login",params="registration")
    public String register(...) {
       ...
    }
    Your HTML would then look something like this:

    Code:
    <form action="<c:url value="/j_spring_security_check"/>" method="POST">
        ...
        <input type="submit" name="login" value="Login"/>
        <input type="submit" name="registration" value="Registration"/>
    </form>
    Rob Winch - @rob_winch
    Spring Security Lead
    Pivotal

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •