jsp exception

Reply

Join Date: Jul 2008
Posts: 9
Reputation: sangham is an unknown quantity at this point 
Solved Threads: 0
sangham sangham is offline Offline
Newbie Poster

jsp exception

 
0
  #1
Aug 28th, 2008
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,
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 4,118
Reputation: peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of 
Solved Threads: 471
Moderator
Featured Poster
peter_budo's Avatar
peter_budo peter_budo is offline Offline
Code tags enforcer

Re: jsp exception

 
0
  #2
Aug 28th, 2008
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?
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)

LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 9
Reputation: sangham is an unknown quantity at this point 
Solved Threads: 0
sangham sangham is offline Offline
Newbie Poster

Re: jsp exception

 
0
  #3
Aug 28th, 2008
Hi this is the databse related code


  1. public class ProductSearchDAOOracleImpl extends OracleDAOImpl implements ProductSearchDAO {
  2. private String QUERY_GETCATEGORY = "SELECT * FROM Category";
  3. //ProductSearchForm productsearchform=(ProductSearchForm) form;
  4. private ArrayList categoryArray= new ArrayList() ;
  5. @Override
  6. public ProductSearchDBVO getCategory()
  7. throws DatabaseException {
  8. ProductSearchDBVO productsearchDBVO = null;
  9. Connection conn = null;
  10. PreparedStatement pstmt = null;
  11. ResultSet resultSet = null;
  12.  
  13. try {
  14. conn = getConnection();
  15. } catch (Exception e) {
  16. // TODO Auto-generated catch block
  17. e.printStackTrace();
  18. throw new DatabaseException(e);
  19. }
  20.  
  21. try {
  22. pstmt = conn.prepareStatement(QUERY_GETCATEGORY);
  23. resultSet = pstmt.executeQuery();
  24. while (resultSet.next()) {
  25. productsearchDBVO=new ProductSearchDBVO();
  26. productsearchDBVO.setProductCategory(resultSet.getString(1));
  27. categoryArray.add(productsearchDBVO);
  28. }
  29.  
  30.  
  31. }catch (SQLException e) {
  32. // TODO Auto-generated catch block
  33. e.printStackTrace();
  34. throw new DatabaseException(e);
  35. }finally {
  36. // Close all the resources properly.
  37. closeResources(resultSet, pstmt, conn);
  38. }
  39.  
  40. return productsearchDBVO;
  41. }
  42.  
  43. }
Last edited by peter_budo; Aug 28th, 2008 at 5:50 am. Reason: Keep It Organized - please use [code] tags
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 4,118
Reputation: peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of 
Solved Threads: 471
Moderator
Featured Poster
peter_budo's Avatar
peter_budo peter_budo is offline Offline
Code tags enforcer

Re: jsp exception

 
0
  #4
Aug 28th, 2008
I think in
  1. 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);
}
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)

LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC