• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JasperException: Cannot find bean under name contractors

 
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I keep getting errors trying to do html:select/html:options in a form. I'm not understanding how to code the tag, whether with property or collection attributes and how the interaction works with the Action class and the struts-config.xml. Can someone show me the syntax for all three files, please? I'm looking for a simple implementation. Here is what I've got:
JSP------------
<%@ page import="java.sql.*"%>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html"%>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"%>
<html>
<head></head>
<body>
<html:form action="/select">
<html:select property="select" >
<html:options property="names" />
</html:select>
</html:form>
</body>
</html>
STRUTS-CONFIG.XML---------------------
...
<form-beans>
<form-bean name="selectForm" type="com.test.struts.form.SelectForm">
<form-property name="select" />
<form-property name="names" type="java.lang.String" />
</form-bean>
</form-beans>
...
SELECTACTION.JAVA----------------------
try{
SelectForm selectForm = (SelectForm) form;
DataSource ds = (DataSource )servlet.getServletContext().getAttribute(Action.DATA_SOURCE_KEY);
Connection con = ds.getConnection();
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("select LAST_NM from MY_TBL");
ArrayList arrayList= new ArrayList();
while(rs.next())
{
arrayList.add(new org.apache.struts.util.LabelValueBean(rs.getString(1)));
}
selectForm.setNames(al);
request.getSession().setAttribute("names", al);
SELECTFORM.JAVA---------------------
public class SelectForm extends ActionForm {
private String select;
private String names;
public String getSelect() { return select; }
public void setSelect(String select) { this.select = select; }
public String getNames() { return names; }
public void setNames(String names) { this.names= names; }
}
 
Jeff Horan
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry, the error reads contractors, substitue names in there.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is best moved to the Struts forum.
bear
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic