• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Rob Spoor
  • Devaka Cooray
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Jj Roberts
  • Al Hobbs
  • Piet Souris

Spring problem with Binding

 
Ranch Hand
Posts: 80
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

https://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.... ''
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Where does "custView" come from ? What are you trying to do ?

And please UseCodeTags.
 
Marc Cracco
Ranch Hand
Posts: 80
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 80
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry didn't realize about the code tags... Will use from now on...
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic