title: Implementing Forgot password in Spring giving garbage URL
body: <p>I am working on a Spring-MVC application. I want to implement the forgot password functionality. For that, I am using the secret question method. I have created a JSP page, where I recieve the values like username, secretanswer and then I check if the values exist and then save the new password which the user has given. I am having a problem wiht the JSP page, when I click submit, it shows me some garbage URL. I believe it is some tiny mistake, I am unable to see. Kindly let me know what is going wrong.</p>
  
  <p>Apache tomcat error URL :</p>
  
  <pre><code>HTTP Status 404 - /id=0,%20username=null,%20password=null
  </code></pre>
  
  <p>Controller function for changing password :</p>
  
  <pre><code> @RequestMapping(value = "/forgotpassword")
      public String forgotPassword(Model model){
         model.addAttribute("person",new Person());
         return "forgotpassword";
      }
  
      @RequestMapping(value = "/changepassword")
      public String changepassword(@ModelAttribute("person") Person f,Model model){
          System.out.println("Did we reach here on submit");
          personService.checkAuthenticitiy(f.getUsername(), f.getSecretanswer(), f.getNewpassword());
          model.addAttribute("person", new Person());
          return "redirect:/forgotpassword";
      }
  </code></pre>
  
  <p>JSP page :</p>
  
  <pre><code>&lt;%@ page contentType="text/html;charset=UTF-8" language="java" %&gt;
  &lt;html&gt;
  &lt;head&gt;
      &lt;title&gt;Forgot Passsword page&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  
  &lt;td&gt;&lt;a href="&lt;c:url value='/' /&gt;" &gt;Go Home&lt;/a&gt;&lt;/td&gt;
  
  &lt;h1&gt;
      Change password
  &lt;/h1&gt;
  
  &lt;c:url var="addAction" value="/changepassword" &gt;&lt;/c:url&gt;
  &lt;form:form action="${person}" commandName="person"&gt;
  &lt;table&gt;
          &lt;tr&gt;
              &lt;td&gt;
                  &lt;form:label path="username"&gt;
                      &lt;spring:message text="username"/&gt;
                  &lt;/form:label&gt;
              &lt;/td&gt;
              &lt;td&gt;
                  &lt;form:input path="username"  /&gt;
              &lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;
                  &lt;form:label path="secretquestion" &gt;
                      &lt;spring:message text="secretquestion"/&gt;
                  &lt;/form:label&gt;
              &lt;/td&gt;
              &lt;td&gt;
                  &lt;form:input path="secretquestion"/&gt;
              &lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;
                  &lt;form:label path="secretanswer" &gt;
                      &lt;spring:message text="secretanswer"/&gt;
                  &lt;/form:label&gt;
              &lt;/td&gt;
              &lt;td&gt;
                  &lt;form:input path="secretanswer"/&gt;
              &lt;/td&gt;
          &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;
              &lt;form:label path="newpassword" &gt;
                  &lt;spring:message text="newpassword"/&gt;
              &lt;/form:label&gt;
          &lt;/td&gt;
          &lt;td&gt;
              &lt;form:input path="newpassword"/&gt;
          &lt;/td&gt;
      &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;
                  &lt;input name="submit" type="submit" value="Submit" /&gt;
              &lt;/td&gt;
          &lt;/tr&gt;
          &lt;/table&gt;
      &lt;/form:form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Person model :</p>
  
  <pre><code>@Entity
  @Table(name="person")
  public class Person implements UserDetails{
  
   @Column(name = "username")
      private String username;
  
  
      @Column(name = "password")
      private String password;
  
      @Column(name = "secretquestion")
      private String secretquestion;
  
      @Column(name = "secretanswer")
      private String secretanswer;
  
      @Transient
      private String newpassword;
       //Getters and setters for all.
  
  }
  </code></pre>