0

Hi friends,

I am using struts framework. I problem is I have fetched the data from from the databse in arraylist and want to display in the drop down here is the code i have written

<html:select property="productCategory">
<html:options collection="array" />
</html:select>

But I am getting following exception:
javax.servlet.ServletException: javax.servlet.jsp.JspException: Cannot find bean under name array

I have this line in my action class:
request.setAttribute("array",categoryList);

Please tell me where am i going wrong

Thanks,

2
Contributors
3
Replies
4
Views
8 Years
Discussion Span
Last Post by peter_budo
0

As message says "Cannot find bean under name array".
Did you stored data retrieved from database in this bean?
Can you post the section of code for DB data retrieval?

0

Hi this is the databse related code

public class ProductSearchDAOOracleImpl extends OracleDAOImpl implements ProductSearchDAO {
	private String QUERY_GETCATEGORY = "SELECT * FROM Category";
	//ProductSearchForm productsearchform=(ProductSearchForm) form;
	private ArrayList categoryArray= new ArrayList() ;	
	@Override
	public ProductSearchDBVO getCategory() 
	       throws DatabaseException {
		ProductSearchDBVO productsearchDBVO = null;
		Connection conn = null;
		PreparedStatement pstmt = null;
		ResultSet resultSet = null;
		
		try {
			conn = getConnection();
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			throw new DatabaseException(e);
		}

		try {
			pstmt = conn.prepareStatement(QUERY_GETCATEGORY);
			resultSet = pstmt.executeQuery();
			while (resultSet.next()) {
				productsearchDBVO=new ProductSearchDBVO();
				productsearchDBVO.setProductCategory(resultSet.getString(1));
			categoryArray.add(productsearchDBVO);
			}
			
			
	}catch (SQLException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
		throw new DatabaseException(e);
	}finally {
	// Close all the resources properly.
	closeResources(resultSet, pstmt, conn);
	}

	return productsearchDBVO;
	}
	
}
0

I think in

request.setAttribute("array",categoryList);

you actually wanted to say

request.setAttribute("array",categoryArray);

as it is where all DB results going

while (resultSet.next()) {
	productsearchDBVO=new ProductSearchDBVO();
	productsearchDBVO.setProductCategory(resultSet.getString(1));
	categoryArray.add(productsearchDBVO);
}
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.