title: Form navigation confusion in Spring
body: <p>I am working on a Spring project </p>
  
  <p>From the Controller AddForm.java a request is forwarded to a Form.jsp &amp; onsubmit from there comes back to the same controller. </p>
  
  <p>Code below</p>
  
  <p>Form.jsp</p>
  
  <pre><code>&lt;%@ include file="/WEB-INF/view/include.jsp" %&gt;
  &lt;%@ include file="/WEB-INF/view/header.jsp" %&gt;
  &lt;c:choose&gt;
      &lt;c:when test="${action eq 'addowner'}"&gt;&lt;c:set var="method" value="post"/&gt;&lt;/c:when&gt;
      &lt;c:otherwise&gt;&lt;c:set var="method" value="put"/&gt;&lt;/c:otherwise&gt;
  &lt;/c:choose&gt;
  
  &lt;h2&gt;&lt;c:if test="${action eq 'addowner'}"&gt;New &lt;/c:if&gt;Owner:&lt;/h2&gt;
  &lt;form:form modelAttribute="owner" method="${method}"&gt;
    &lt;table&gt;
      &lt;tr&gt;
        &lt;th&gt;
          First Name:
          &lt;br/&gt;
          &lt;form:input path="firstName" size="30" maxlength="80"/&gt;
        &lt;/th&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;th&gt;
          Last Name:
          &lt;br/&gt;
          &lt;form:input path="lastName" size="30" maxlength="80"/&gt;
        &lt;/th&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;th&gt;
          Address:
          &lt;br/&gt;
          &lt;form:input path="address" size="30" maxlength="80"/&gt;
        &lt;/th&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;th&gt;
          City:
          &lt;br/&gt;
          &lt;form:input path="city" size="30" maxlength="80"/&gt;
        &lt;/th&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;th&gt;
          Telephone:
          &lt;br/&gt;
          &lt;form:input path="telephone" size="20" maxlength="20"/&gt;
        &lt;/th&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;
          &lt;c:choose&gt;
            &lt;c:when test="${action eq 'addowner'}"&gt;
              &lt;p class="submit"&gt;&lt;input type="submit" value="Add Owner"/&gt;&lt;/p&gt;
            &lt;/c:when&gt;
            &lt;c:otherwise&gt;
              &lt;p class="submit"&gt;&lt;input type="submit" value="Update Owner"/&gt;&lt;/p&gt;
            &lt;/c:otherwise&gt;
          &lt;/c:choose&gt;
        &lt;/td&gt;
      &lt;/tr&gt;
    &lt;/table&gt;
  &lt;/form:form&gt;
  
  &lt;%@ include file="/WEB-INF/view/footer.jsp" %&gt;
  </code></pre>
  
  <p>AddFormController code</p>
  
  <pre><code>    @Controller
  @RequestMapping("/owners/new")
  @SessionAttributes(types = Owner.class)
  public class AddOwnerForm {
  
      private final Clinic clinic;
  
  
      @Autowired
      public AddOwnerForm(Clinic clinic) {
          this.clinic = clinic;
      }
  
      @InitBinder
      public void setAllowedFields(WebDataBinder dataBinder) {
          dataBinder.setDisallowedFields("id");
      }
  
      @RequestMapping(method = RequestMethod.GET)
      public String setupForm(Model model) {
          Owner owner = new Owner();
          model.addAttribute(owner);
          model.addAttribute("action", "addowner");
          return "owners/form";
      }
  
      @RequestMapping(method = RequestMethod.POST)
      public String processSubmit(@ModelAttribute Owner owner, SessionStatus status) {
  
              System.out.println(owner.toString());
              System.out.println("Inside AddOwner processSubmit method");
              this.clinic.storeOwner(owner);
              status.setComplete();
              return "redirect:/forms/owners/" + owner.getId();
  
      }
  
  }
  </code></pre>
  
  <p>The problem is in the controller the setupForm method forwards the flow to the jsp but in jsp in the form tag nowhere action is given but on submit the flow comes back to the 
  processSubmit method. Can anyone tell me why?</p>