aspose file tools*
The moose likes JSP and the fly likes JasperException: Cannot find bean under name contractors Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "JasperException: Cannot find bean under name contractors" Watch "JasperException: Cannot find bean under name contractors" New topic
Author

JasperException: Cannot find bean under name contractors

Jeff Horan
Ranch Hand

Joined: Apr 03, 2003
Posts: 37
I keep getting errors trying to do html:select/htmlptions 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" >
<htmlptions 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; }
}


jh
Jeff Horan
Ranch Hand

Joined: Apr 03, 2003
Posts: 37
Sorry, the error reads contractors, substitue names in there.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61413
    
  67

This is best moved to the Struts forum.
bear


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JasperException: Cannot find bean under name contractors