Java Mailing List Archive

http://www.gg3721.com/

Home » Struts Users Mailing List »

Cannot find bean: "bookList" in any scope

tesla

2010-03-07

Replies: Find Java Web Hosting

Author LoginPost Reply

Hi i'm new at struts.I wanna write all the array elements which i defined at
java class to the jsp file
but i'm getting this error
"javax.servlet.ServletException: javax.servlet.jsp.JspException: Cannot find
bean: "bookList" in any scope"
Here is my code
Thx for helping

Book.JAVA

public class Book {

  private String name;
  private int price;
  //private List books=new ArrayList();

  Connection con ;
  Statement ps;
  ResultSet rs;

  public ArrayList listBook() throws SQLException
  {
    ArrayList books=new ArrayList();
    try
    {
      Class.forName("com.mysql.jdbc.Driver");
       con =
DriverManager.getConnection("jdbc:mysql://localhost:3306/logintest_development","root","pass");
       ps = con.createStatement();
       rs = ps.executeQuery("SELECT * FROM books");
       while(rs.next()){
          books.add(new perInfoBook(rs.getString("title")));
       }

    }
  catch (Exception e)
  {
   System.out.println("Error Data : " + e.getMessage());
  }
    con.close();
    return books;
  }
 


public class perInfoBook
{
  String title;
 int bookid;
 
  public perInfoBook(String title) {
    this.title = title;
   
  }

public String getTitle() {
return title;
}
public int getBookid() {return bookid;}

}
}


BookForm.JAVA

public class BookForm extends ActionForm{
 
 private List bookList;

public void reset(ActionMapping mapping,HttpServletRequest request){
 bookList=new ArrayList();
}

BookAction.Java

public class BookAction extends Action{

public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request,    HttpServletResponse response) throws
Exception {

BookForm bookForm = (BookForm) form;
Book book = new Book();
bookForm.setBookList(book.listBook());
return mapping.findForward("success");

}
}

and here is my jsp code

<body>
      <logic:iterate id="Table" name="bookList" >
        <tr>
          <td><bean:write name="Table" property="title"/></td>
        </tr>
      </logic:iterate>
</body>



--
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@(protected)
For additional commands, e-mail: user-help@(protected)

©2008 gg3721.com - Jax Systems, LLC, U.S.A.