title: Java, Spring, JSP, <form>. Neither BindingResult nor plain target object for bean name 'command' available as request attribute
body: <p><strong>Hey, everyone!</strong> </p>
  
  <p>I can't understand why it happens when I try to open webapp:</p>
  
  <pre><code>Neither BindingResult nor plain target object for bean name 'command' available as request attribute
  </code></pre>
  
  <p>and</p>
  
  <pre><code>org.apache.jasper.JasperException: An exception occurred processing JSP page /index.jsp at line 53
  </code></pre>
  
  <p>Here is <code>form</code> from index.jsp</p>
  
  <pre><code>51 &lt;c:url var="addAction" value="/email/add.form"/&gt;
  52 &lt;form:form action="${addAction}" commandName="command"&gt;
  53    &lt;form:input path="email" type="email" placeholder="Enter email" class="cell"/&gt;
  54    &lt;input type="submit" class="button" value="&lt;spring:message text="Send"/&gt;"/&gt;
  55 &lt;/form:form&gt;
  </code></pre>
  
  <p>Here is Controller</p>
  
  <pre><code>@Controller
  public class EmailController {
      private EmailService emailService;
  
      @Autowired
      @Qualifier("emailService")
      public void setEmailService(EmailService emailService) {
          this.emailService = emailService;
      }
  
      @RequestMapping(value = "/email/add", method = RequestMethod.POST)
      public String addEmail(@ModelAttribute("email") EmailEntity emailEntity) {
          this.emailService.addEmail(emailEntity);
          return "redirect:/email.form";
      }
  }
  </code></pre>
  
  <p>The following is Stacktrace and Root Cause</p>
  
  <pre><code>Stacktrace:
      org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:584)
      org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:476)
      org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:385)
      org.apache.jasper.servlet.JspServlet.service(JspServlet.java:329)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
      org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
  Root Cause
  
  java.lang.IllegalStateException: Neither BindingResult nor plain target object for bean name 'command' available as request attribute
      org.springframework.web.servlet.support.BindStatus.&lt;init&gt;(BindStatus.java:144)
      org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.getBindStatus(AbstractDataBoundFormElementTag.java:168)
      org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.getPropertyPath(AbstractDataBoundFormElementTag.java:188)
      org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.getName(AbstractDataBoundFormElementTag.java:154)
      org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.autogenerateId(AbstractDataBoundFormElementTag.java:141)
      org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.resolveId(AbstractDataBoundFormElementTag.java:132)
      org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.writeDefaultAttributes(AbstractDataBoundFormElementTag.java:116)
      org.springframework.web.servlet.tags.form.AbstractHtmlElementTag.writeDefaultAttributes(AbstractHtmlElementTag.java:422)
      org.springframework.web.servlet.tags.form.InputTag.writeTagContent(InputTag.java:142)
      org.springframework.web.servlet.tags.form.AbstractFormTag.doStartTagInternal(AbstractFormTag.java:84)
      org.springframework.web.servlet.tags.RequestContextAwareTag.doStartTag(RequestContextAwareTag.java:80)
      org.apache.jsp.index_jsp._jspx_meth_form_005finput_005f0(index_jsp.java:323)
      org.apache.jsp.index_jsp._jspx_meth_form_005fform_005f0(index_jsp.java:271)
      org.apache.jsp.index_jsp._jspService(index_jsp.java:184)
      org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
      org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:443)
      org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:385)
      org.apache.jasper.servlet.JspServlet.service(JspServlet.java:329)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
      org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
  </code></pre>
  
  <p>Sorry, if something has been missed.
  Thanks!</p>