wood burning stoves 2.0*
The moose likes Spring and the fly likes Spring problem with Binding Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Spring problem with Binding" Watch "Spring problem with Binding" New topic
Author

Spring problem with Binding

Marc Cracco
Ranch Hand

Joined: Mar 09, 2010
Posts: 79
    
    1
Hi,

I'm getting a
javax.servlet.jsp.JspTagException: Neither BindingResult nor plain target object for bean name 'custView' available as request attribute
error in my code. I've been looking and down for 2 days now but can't find my problem.

Sorry if this error turn out to be easy, I'm very new to Spring and EE, just started a little while ago...

Here is my relevant code...


-------CustomerSearchController.java-------- (has all needed imports)

public class CustomerSearchController extends SimpleFormController {

private CustomerService customerService;

public CustomerSearchController() {
setCommandClass(CustomerSearchObject.class);
setCommandName("search");
setSuccessView("./customer/custList"); //THIS IS WHERE IT LOADS MY NEXT JSP
setFormView("./customer/custSearch"); //LOADS CORRECTLY AND RUNS onSubmit() with no problem
}

public void setCustomerService(CustomerService customerService){
this.customerService = customerService;
}

@Override
protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object command, BindException errors) throws Exception {

List<Customer> list = customerService.getCustomer((CustomerSearchObject)command);

ModelAndView mv = new ModelAndView();
mv.addObject("list", list);

mv.setViewName(getSuccessView());
return mv;
}
}

----custList.jsp-----//LOADS ON SUCCESS OF CustomerSearchController.java
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib uri="http://www.springframework.org/tags" prefix="spring" %>

<%@page import="java.util.*,com.myfuturesolution.tailwaggers.hibernate.Customer"%>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" href="./css/custFormCss.css">
</head>
<body>
//just some html code here
<%
List<Customer> list = (List<Customer>) request.getAttribute("list");
if (list.size() != 0){
for (Customer c: list){
%>
//THIS IS WHERE THE PROBLEM START???
<spring:nestedPath path="custView">
<form name="<% out.print(c.getId());%>" target="indexUpperIframe" action="" method="post">
<spring:bind path="searchType">
<input type="hidden" name="${status.expression}" value="<% out.print(c.getId());%>"/>
</spring:bind>
</form>
</spring:nestedPath>
//More HTML goes here.....

if you need to see mydispatcher-servlet.xml or more code let me know

Here is the error I get

org.apache.jasper.JasperException: An exception occurred processing JSP page /WEB-INF/jsp/customer/custList.jsp at line 41

38: %>
39: <spring:nestedPath path="custView">
40: <form name="<% out.print(c.getId());%>" target="indexUpperIframe" action="" method="post">
41: <spring:bind path="searchType">
42: <input type="hidden" name="${status.expression}" value="<% out.print(c.getId());%>"/>
43: </spring:bind>
44: </form>

Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:510)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:401)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:167)
org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:239)
org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1158)
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:900)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:808)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:476)
org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:441)
javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

root cause

javax.servlet.ServletException: javax.servlet.jsp.JspTagException: Neither BindingResult nor plain target object for bean name 'custView' available as request attribute
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:862)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:791)
org.apache.jsp.WEB_002dINF.jsp.customer.custList_jsp._jspService(custList_jsp.java:201)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:167)
org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:239)
org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1158)
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:900)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:808)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:476)
org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:441)
javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

root cause

javax.servlet.jsp.JspTagException: Neither BindingResult nor plain target object for bean name 'custView' available as request attribute
org.springframework.web.servlet.tags.BindTag.doStartTagInternal(BindTag.java:120)
org.springframework.web.servlet.tags.RequestContextAwareTag.doStartTag(RequestContextAwareTag.java:77)
org.apache.jsp.WEB_002dINF.jsp.customer.custList_jsp._jspService(custList_jsp.java:125)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:167)
org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:239)
org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1158)
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:900)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:808)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:476)
org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:441)
javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)


I searched online first to see if I could find a solution and actually found this javarach post.

http://www.coderanch.com/t/422525/EJB-Other-Java-EE-Technologies/java/SprngFramework-Form-Binding-Error

I am not accessing my JSP directly... Not sure what is going on.... ''


SCJP 6 [ My stuff ]
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

Where does "custView" come from ? What are you trying to do ?

And please UseCodeTags.

[My Blog]
All roads lead to JavaRanch
Marc Cracco
Ranch Hand

Joined: Mar 09, 2010
Posts: 79
    
    1
Sorry should have posted the following file
-----CustomerViewController.java-----
public class CustomerViewController extends SimpleFormController {

private CustomerService customerService;

public void setCustomerService(CustomerService customerService){
this.customerService = customerService;
}

public CustomerViewController() {
//Initialize controller properties here or
//in the Web Application Context

setCommandClass(CustomerSearchObject.class);
setCommandName("custView");
setSuccessView("./customer/showCustView");
setFormView("./customer/custList");
}

@Override
protected void doSubmitAction(Object command) throws Exception {
throw new UnsupportedOperationException("Not yet implemented");
}

}

I am trying to the CustomerSearchObject in this controller to the field in the JSP

the custList.jsp is the form for this controller....
Marc Cracco
Ranch Hand

Joined: Mar 09, 2010
Posts: 79
    
    1
Sorry didn't realize about the code tags... Will use from now on...
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Spring problem with Binding
 
Similar Threads
error compiling view with spring mvc project
I have got this error when i try to run my spring web project.... what is this error?
Error on View - MultiActionController + Spring:bine
what is this error
MySQL