javax.servlet.jsp.JspTagException: Neither BindingResult nor plain target object for bean name 'employee' available as request attribute ________________________________________________________________________
In jsp i have, <spring:bind path="credentials.propertyName">
In spring xml file i have command name as, <property name="commandName">credentials</property> <property name="commandClass">LoginCredentials</property>
In controller class i have code,
protected Object formBackingObject(HttpServletRequest req) { LoginCredentials loginCredentials=new LoginCredentials(); HttpSession ses=req.getSession(true); ses.setAttribute("credentials",loginCredentials); return loginCredentials; } I am getting below issue.
exception
org.apache.jasper.JasperException: javax.servlet.ServletException: javax.servlet.jsp.JspTagException: Neither BindingResult nor plain target object for bean name 'credentials' available as request attribute org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:541) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:417) 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)
As i konw many had asked this question previously. I checked previous mails ,but the issue not getting soled can any one help me to resolve the issue
import org.springframework.validation.Errors; import org.springframework.validation.ValidationUtils; import org.springframework.validation.Validator; public class LoginCredentialValidator implements Validator { LoginCredentials loginCredentials;
public boolean supports(Class c) { return LoginCredentials.class.isAssignableFrom(c); }
public void validate(Object commandObject,Errors errors) { ValidationUtils.rejectIfEmptyOrWhitespace(errors,"userName","Field is required"); ValidationUtils.rejectIfEmptyOrWhitespace(errors,"password","Field is required");
loginCredentials=(LoginCredentials)commandObject; if((loginCredentials.getPassword()!="password") && (loginCredentials.getUsername()!="xyz")) { errors.reject("credentials provided are not correctd"); }
}
}
murwath ali
Greenhorn
Joined: Dec 24, 2008
Posts: 4
posted
0
When I deploy the application in the server i get an exception ,
The "javax.servlet.ServletException: javax.servlet.jsp.JspTagException: Neither BindingResult nor plain target object for bean name 'credentials' available as request attribute" generally pops up when you directly access your jsp page which has binding to the controller.
To solve it, kindly access the URL according to the mapping in your spring confing file, access the controller first then it will certainly map to your jsp page automatically.