title: java.lang.IllegalStateException: Neither BindingResult nor plain target object for bean name 'logpo' available as request attribute
body: <p>i am trying to use spring validation using annotation.But when am running the application,it gives following exception-</p>
  
  <pre><code>org.apache.catalina.core.StandardWrapperValve invoke
  SEVERE: Servlet.service() for servlet [jsp] in context with path [/SpringTest] threw 
  exception [java.lang.IllegalStateException: Neither BindingResult nor plain target     
  object for bean name 'logpo' available as request attribute] with root cause
  java.lang.IllegalStateException: Neither BindingResult nor plain target object for bean    
   name 'logpo' available as request attribute
  at org.springframework.web.servlet.support.BindStatus.&lt;init&gt;(BindStatus.java:141)
  at org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.getBindStatus(AbstractDataBoundFormElementTag.java:174)
  at org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.getPropertyPath(AbstractDataBoundFormElementTag.java:194)
  at org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.getName(AbstractDataBoundFormElementTag.java:160)
  at org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.autogenerateId(AbstractDataBoundFormElementTag.java:147)
  at org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.resolveId(AbstractDataBoundFormElementTag.java:138)
  at org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.writeDefaultAttributes(AbstractDataBoundFormElementTag.java:122)
  at org.springframework.web.servlet.tags.form.AbstractHtmlElementTag.writeDefaultAttributes(AbstractHtmlElementTag.java:408)
  at org.springframework.web.servlet.tags.form.InputTag.writeTagContent(InputTag.java:140)
  at org.springframework.web.servlet.tags.form.AbstractFormTag.doStartTagInternal(AbstractFormTag.java:102)
  at org.springframework.web.servlet.tags.RequestContextAwareTag.doStartTag(RequestContextAwareTag.java:79)
  at org.apache.jsp.index_jsp._jspx_meth_form_005finput_005f0(index_jsp.java:196)
  at org.apache.jsp.index_jsp._jspService(index_jsp.java:98)
  at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
  at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
  at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
  at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
  at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
  at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
  at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:225)
  at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169)
  at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
  at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
  at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
  at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927)
  at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
  at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
  at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:999)
  at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:565)
  at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:307)
  at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
  at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
  at java.lang.Thread.run(Unknown Source)
  </code></pre>
  
  <p>i have tried ,but not able to solve this .
  index.jsp
  In this page there is two fields for username and password.</p>
  
  <pre><code>&lt;%@ page language="java" contentType="text/html; charset=ISO-8859-1"
  pageEncoding="ISO-8859-1"%&gt;
  &lt;%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%&gt;
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"  
  "http://www.w3.org/TR/html4/loose.dtd"&gt;
   &lt;html&gt;
   &lt;head&gt;
  &lt;meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"&gt;
  &lt;title&gt;Login Page&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;form:form action="login.do" commandName="logpo" method="GET"&gt;
  Enter name :
  &lt;form:input path="uname"  /&gt;
  &lt;form:errors path="uname" /&gt;&lt;br&gt;
  Enter pass :
  &lt; form:input path="password"/&gt;
  &lt;form:errors path="password"/&gt;
  &lt;input type="submit" value="In" /&gt;
  &lt;/form:form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Web.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
  id="WebApp_ID"
  version="2.5"
  xmlns="http://java.sun.com/xml/ns/javaee"
  xsi:schemaLocation="http://java.sun.com/xml/ns/javaee     
  http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" &gt;
  
  &lt;display-name&gt;SpringTest&lt;/display-name&gt;
  &lt;welcome-file-list&gt;
      &lt;welcome-file&gt;index.jsp&lt;/welcome-file&gt;
  &lt;/welcome-file-list&gt;
  &lt;listener&gt;
      &lt;listener-class&gt;org.springframework.web.context.ContextLoaderListener&lt;/listener-
  class&gt;
  &lt;/listener&gt;
  
  &lt;servlet&gt;
      &lt;servlet-name&gt;dispatcher&lt;/servlet-name&gt;
      &lt;servlet-class&gt;org.springframework.web.servlet.DispatcherServlet&lt;/servlet-class&gt;
      &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
  &lt;/servlet&gt;
  
  &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;dispatcher&lt;/servlet-name&gt;
      &lt;url-pattern&gt;*.do&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
  
  
  &lt;context-param&gt;
    &lt;param-name&gt;log4jConfigLocation&lt;/param-name&gt;
    &lt;param-value&gt;/WEB-INF/resources/log4j.properties&lt;/param-value&gt;
  &lt;/context-param&gt;
  
   &lt;listener&gt;
      &lt;listener-class&gt;org.springframework.web.util.Log4jConfigListener&lt;/listener-class&gt;
  &lt;/listener&gt;
  
  &lt;/web-app&gt;
  </code></pre>
  
  <p>dispacher-servel.xml</p>
  
  <pre><code>&lt;beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns="http://www.springframework.org/schema/beans"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:mvc="http://www.springframework.org/schema/mvc"
  xsi:schemaLocation="http://www.springframework.org/schema/beans
             http://www.springframework.org/schema/beans/spring-beans-3.0.xsd 
             http://www.springframework.org/schema/context
  http://www.springframework.org/schema/context/spring-context-3.0.xsd
  http://www.springframework.org/schema/mvc 
  http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd"&gt;
  
  &lt;mvc:annotation-driven/&gt;
  
  &lt;!--    Dispacher --&gt;
  &lt;bean
      id="viewResolver"
      class="org.springframework.web.servlet.view.InternalResourceViewResolver" &gt;
      &lt;property
          name="prefix"
          value="" /&gt;
  
      &lt;property
          name="suffix"
          value=".jsp" /&gt;
  &lt;/bean&gt;
  
  &lt;bean class="org.springframework.context.support.ResourceBundleMessageSource"
      id="messageSource"&gt;
      &lt;property name="basename" value="messages" /&gt;
  &lt;/bean&gt;
  
  
  
  &lt;/beans&gt;
  </code></pre>
  
  <p>and controller is
  LoginController.java</p>
  
  <pre><code> package com.controller;
  
   import java.util.Iterator;
   import java.util.List;
   import javax.servlet.http.HttpServletRequest;
   import javax.validation.Valid;
  
   import org.apache.log4j.Logger;
   import org.hibernate.Query;
   import org.hibernate.Session;
   import org.hibernate.SessionFactory;
   import org.springframework.stereotype.Controller;
   import org.springframework.validation.BindingResult;
   import org.springframework.web.bind.annotation.RequestMapping;
   import org.springframework.web.bind.annotation.RequestMethod;
   import org.springframework.web.servlet.ModelAndView;
  
   import com.util.HibernateUtil;
   import com.util.LoginPojo;
  
   @Controller
   public class LoginController {
  private static final Logger logger = Logger
          .getLogger(LoginController.class);
  private LoginPojo llogin;
  
  @RequestMapping(value = "/login", method = RequestMethod.GET)
  public ModelAndView loginAuth(@Valid LoginPojo logpo ,BindingResult     
    br,HttpServletRequest req,ModelAndView mav) {
      logger.info("loginAuth method");
      //ModelAndView mav = new ModelAndView();
      if(br.hasErrors()){
           mav.setViewName("index");
      }else{
                      mav.setViewName("success");
    }
  </code></pre>
  
  <p>and i have added all required jar .</p>