You have bookList and listBook.  Change one of them.

On Sun, Mar 7, 2010 at 8:25 PM, tesla <fatihdu...@hotmail.com> wrote:

>
> 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>
>
>
>
> --
> View this message in context:
> http://old.nabble.com/Cannot-find-bean%3A-%22bookList%22-in-any-scope-tp27816517p27816517.html
> Sent from the Struts - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
> For additional commands, e-mail: user-h...@struts.apache.org
>
>

Reply via email to