title: Spring MVC -- Neither BindingResult nor plain target object for bean name 'command' available as request attribute
body: <p>I'm working on a Spring 3.1 MVC application, and my JSP won't come up.  I am getting the following in my browser screen.</p>
  
  <pre><code>org.apache.jasper.JasperException: An exception occurred processing JSP page /GuestBook.jsp at line 31
  
  28:     &lt;form:form method="post" action="GuestBook.jsp"&gt;
  29:         &lt;table&gt;
  30:             &lt;tr&gt;
  31:                 &lt;td&gt;&lt;form:label path="comment.name"&gt;Name&lt;/form:label&gt;&lt;/td&gt;
  32:                 &lt;td&gt;&lt;form:input path="comment.name" /&gt;&lt;/td&gt;
  33:             &lt;/tr&gt;
  34:             &lt;tr&gt;
  
  
  Stacktrace:
      org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:524)
      org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:429)
      org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
      org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
  
  
  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:141)
      org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.getBindStatus(AbstractDataBoundFormElementTag.java:174)
      org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.getPropertyPath(AbstractDataBoundFormElementTag.java:194)
      org.springframework.web.servlet.tags.form.LabelTag.autogenerateFor(LabelTag.java:129)
      org.springframework.web.servlet.tags.form.LabelTag.resolveFor(LabelTag.java:119)
      org.springframework.web.servlet.tags.form.LabelTag.writeTagContent(LabelTag.java:89)
      org.springframework.web.servlet.tags.form.AbstractFormTag.doStartTagInternal(AbstractFormTag.java:102)
      org.springframework.web.servlet.tags.RequestContextAwareTag.doStartTag(RequestContextAwareTag.java:79)
      org.apache.jsp.GuestBook_jsp._jspx_meth_form_005flabel_005f0(GuestBook_jsp.java:269)
      org.apache.jsp.GuestBook_jsp._jspx_meth_form_005fform_005f0(GuestBook_jsp.java:214)
      org.apache.jsp.GuestBook_jsp._jspService(GuestBook_jsp.java:127)
      org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
      org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:393)
      org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
      org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
  </code></pre>
  
  <p>Here is the full form.</p>
  
  <pre><code>&lt;form:form method="post" action="GuestBook.jsp"&gt;
      &lt;table&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;form:label path="comment.name"&gt;Name&lt;/form:label&gt;&lt;/td&gt;
              &lt;td&gt;&lt;form:input path="comment.name" /&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;form:label path="comment.message"&gt;Message&lt;/form:label&gt;&lt;/td&gt;
              &lt;td&gt;&lt;form:textarea path="comment.message" rows="10" cols="50" /&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;input type="submit" value="Submit comment" /&gt;&lt;/td&gt;
              &lt;td&gt;&amp;nbsp;&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/table&gt;
  &lt;/form:form&gt;
  </code></pre>
  
  <p>This is what I have in my controller class.</p>
  
  <pre><code>@Controller
  @RequestMapping("GuestBook")
  public class CommentController {
      @RequestMapping(value = "/GuestBook", method = RequestMethod.POST)
      public String addComment(@ModelAttribute("comment") Comment comment, BindingResult result) {
          CommentDAO commentDAO = new CommentDAO();
          java.util.Date today = new java.util.Date();
          java.sql.Date date = new java.sql.Date(today.getTime());
          comment.setDate(date);
  
          if (commentDAO.writeComment(comment) == true) {
              return "redirect:GuestBook.jsp";
          }
  
          return "redirect:Oops.jsp";
      }
  
      @RequestMapping("/GuestBook")
      public ModelAndView showComments() {
          return new ModelAndView("comments", "command", new Comment());
      }
  </code></pre>