Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8540001
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T11:30:00+00:00 2026-06-11T11:30:00+00:00

This is probably a very simple error somewhere. Please help. I have a home.jsp

  • 0

This is probably a very simple error somewhere. Please help.
I have a home.jsp page with two <form:form> tags:

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<%@ taglib uri="/META-INF/c.tld" prefix="c"%>
<%@ taglib uri="/META-INF/fmt.tld" prefix="fmt"%>
<%@ taglib uri="/META-INF/spring-form.tld" prefix="form"%>

<html>

<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">

<head>
    <title>Home Page</title>
</head>

<body>

<div>
    <form:form name="loginForm" modelAttribute="loginUser" action="login" method="post">

        <c:if test="${loginMsg != null}"><c:out value="${loginMsg}"></c:out></c:if>
        <br/>

        Email: <form:input name="loginEmail" id="loginEmail" value=""   path="email"/>
        <form:errors path="email" cssClass="error" />
        <br/>

        password: <form:password name="loginPassword" Id="loginPassword" value="" path="password" />
        <form:errors path="password" />
        <br/>

        <input type="submit" id="id_login" value="Login">

    </form:form>
</div>

<div>
    <form:form name="SignUpForm" modelAttribute="signUpUser" action="signup" method="post">

        <c:if test="${signupMsg != null}"><c:out value="${signupMsg}"></c:out></c:if>   
        <br/>

        Full Name: <form:input name="name" id="name" value=""   path="name"/>
        <form:errors path="name" cssClass="error" />
        <br/>

        Email: <form:input name="signupEmail" id="signupEmail" value="" path="email"/>
        <form:errors path="email" cssClass="error" />
        <br/>

        password: <form:password name="signUpPassword" Id="signUpPassword" value="" path="password" />
        <form:errors path="password" />
        <br/>

        <input type="submit" id="id_signUp" value="Sign Up">

    </form:form>
</div>

</body>

</html>

Each form is handled by a different controller. The problem is, when I fill (just) one of the forms and click the submit button, both the ModelAttributes are getting populated with the same value

There’s nothing special to my controllers:

@RequestMapping("/login")
public String login(@ModelAttribute("loginUser") User user,
        BindingResult result, @ModelAttribute("signUpUser") User signUpUser,
        BindingResult signUpResult, ModelMap model, HttpServletRequest request,
        HttpServletResponse response) {

    // Here, both user and signUpUser have the same value (WHY?)
    // But I dint fill the sign up form at all

    loginFormValidator.validate(user, result);

    if(Errors in `result`)
        return "forward:/home";

    // Authentication Logic
    request.getSession().setAttribute("s_user_obj", some_variable);
    return "forward:/home";

}

UPDATE:

Here’s the HTMLs generated.
BEFORE login action:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>

<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">

<head>
    <title>Welcome to m0m0</title>
</head>

<body>

<div>
    <form id="loginUser" name="loginForm" action="login" method="post">

        <br/>                           
        Email: <input id="loginEmail" name="email" name="loginEmail" type="text" value=""/>

        <br/>
        password: <input id="password" name="password" name="loginPassword" Id="loginPassword" type="password" value=""/>

        <br/>
        <input type="submit" id="id_login" value="Login">

    </form>
</div>

<div>
    <form id="signUpUser" name="SignUpForm" action="signup" method="post">

        <br/>
        Full Name: <input id="name" name="name" name="name" type="text" value=""/>

        <br/>                   
        Email: <input id="signupEmail" name="email" name="signupEmail" type="text" value=""/>

        <br/>
        password: <input id="password" name="password" name="signUpPassword" Id="signUpPassword" type="password" value=""/>

        <br/>
        <input type="submit" id="id_signUp" value="Sign Up">

    </form>
</div>

</body>

</html>

AFTER login action:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>

<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">

<head>
    <title>Welcome to m0m0</title>
</head>

<body>

<div>
    <form id="loginUser" name="loginForm" action="login" method="post">

        <br/>                           
        Email: <input id="loginEmail" name="email" name="loginEmail" type="text" value="a@b.com"/>

        <br/>
        password: <input id="password" name="password" name="loginPassword" Id="loginPassword" type="password" value=""/>

        <br/>
        <input type="submit" id="id_login" value="Login">

    </form>
</div>

<div>
    <form id="signUpUser" name="SignUpForm" action="signup" method="post">

        <br/>
        Full Name: <input id="name" name="name" name="name" type="text" value=""/>

        <br/>                   
        Email: <input id="signupEmail" name="email" name="signupEmail" type="text" value="a@b.com"/>

        <br/>
        password: <input id="password" name="password" name="signUpPassword" Id="signUpPassword" type="password" value=""/>

        <br/>
        <input type="submit" id="id_signUp" value="Sign Up">

    </form>
</div>

</body>

</html>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T11:30:01+00:00Added an answer on June 11, 2026 at 11:30 am

    spring binds the parameters to both models, because it doesn’t consider the model name for binding (and btw. there’s no information about the model name in the request)

    Each form is handled by a different controller.

    but this method handles both?

    @RequestMapping("/login")
    public String login(@ModelAttribute("loginUser") User user,
        BindingResult result, @ModelAttribute("signUpUser") User signUpUser,
        BindingResult signUpResult, ModelMap model, HttpServletRequest request,
        HttpServletResponse response) {
    
    // Here, both user and signUpUser have the same value (WHY?)
    // But I dint fill the sign up form at all
    
    loginFormValidator.validate(user, result);
    
    if(Errors in `result`)
        return "forward:/home";
    
    // Authentication Logic
    request.getSession().setAttribute("s_user_obj", some_variable);
    return "forward:/home";
    

    }

    EDIT:

    public class Form {
        private User loginUser;
        private User signupUser;
        .....
    }
    

    then you can do the following

    <form:input path="loginUser.name" />
    

    and

    <form:input path="signupUser.name" />
    

    in this case you’ll only have 1 model attribute, not 2

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is probably a very simple question so please forgive my ignorance, but can
This is probably a very simple fix. I clicked the form in the Solution
this is probably something very simple to fix. Im posting to a php page
This is probably very simple but it's really confusing me. When I implement the
This is probably a very simple question, I apologise - I'm new to rails.
This is probably a very simple question but I'm a little confused how this
This is probably a very simple Object Oriented Programming question. What I am trying
This is another probably very simple question, but I haven't been able to find
So this one is probably very simple, but I'm having a bit of trouble
I know this is probably a very simple question but how would I do

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.