You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by tesla <fa...@hotmail.com> on 2010/03/08 03:25:41 UTC

Cannot find bean: "bookList" in any scope

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-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Cannot find bean: "bookList" in any scope

Posted by Paweł Wielgus <po...@gmail.com>.
Hi All,
also shouldn't it be < logic:iterate name="bookForm" property="bookList" >?

Best greetings,
Paweł Wielgus.


2010/3/8  <st...@gmail.com>:
> You have bookList and listBook.  Change one of them.
>
> On Sun, Mar 7, 2010 at 8:25 PM, tesla <fa...@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-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: Cannot find bean: "bookList" in any scope

Posted by tesla <fa...@hotmail.com>.
its struts 1 struts version 1.2.9 and also i added this code
"bookForm.getBookList().add("qwer") " to bookAction.java but still i cant
see array elemtens at the browser

its my struts config.xml

<action-mappings>
        <action path="/Welcome" forward="/welcomeStruts.jsp"/>
        <action
        path="/data"
        type="paket.BookAction"
        name="BookForm"
        scope="request"
        input="data.jsp">
        <forward name="success" path="/data.jsp"  redirect="false" />
       </action>
    </action-mappings>




mgainty wrote:
> 
> 
> the short answer is you'll need to populate your arraylist for any of the
> elements in the list to 'show up'
> 
> the long answer is 
> you'll need to supply jsp/struts-config.xml,struts.xml and backend
> beans,contents of Action class
> and which struts version you are implementing on to be able to provide a
> solution for you 
> 
> Martin Gainty 
> ______________________________________________ 
> Verzicht und Vertraulichkeitanmerkung
>  
> Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene
> Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte
> Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht
> dient lediglich dem Austausch von Informationen und entfaltet keine
> rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von
> E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen.
> 
> 
> 
> 
> 
> 
>> Date: Mon, 8 Mar 2010 13:51:10 -0800
>> From: fatihdurdu@hotmail.com
>> To: user@struts.apache.org
>> Subject: Re: Cannot find bean: "bookList" in any scope
>> 
>> 
>> thx for helping but now when i run the application i see an empty page i
>> can't see books which i retrive from my database i guess my arraylist is
>> empty why it is??
>> -- 
>> View this message in context:
>> http://old.nabble.com/Cannot-find-bean%3A-%22bookList%22-in-any-scope-tp27816517p27828192.html
>> Sent from the Struts - User mailing list archive at Nabble.com.
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>> 
>  		 	   		  
> _________________________________________________________________
> Hotmail: Free, trusted and rich email service.
> http://clk.atdmt.com/GBL/go/201469228/direct/01/
> 

-- 
View this message in context: http://old.nabble.com/Cannot-find-bean%3A-%22bookList%22-in-any-scope-tp27816517p27828494.html
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: Cannot find bean: "bookList" in any scope

Posted by Martin Gainty <mg...@hotmail.com>.
the short answer is you'll need to populate your arraylist for any of the elements in the list to 'show up'

the long answer is 
you'll need to supply jsp/struts-config.xml,struts.xml and backend beans,contents of Action class
and which struts version you are implementing on to be able to provide a solution for you 

Martin Gainty 
______________________________________________ 
Verzicht und Vertraulichkeitanmerkung
 
Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen.






> Date: Mon, 8 Mar 2010 13:51:10 -0800
> From: fatihdurdu@hotmail.com
> To: user@struts.apache.org
> Subject: Re: Cannot find bean: "bookList" in any scope
> 
> 
> thx for helping but now when i run the application i see an empty page i
> can't see books which i retrive from my database i guess my arraylist is
> empty why it is??
> -- 
> View this message in context: http://old.nabble.com/Cannot-find-bean%3A-%22bookList%22-in-any-scope-tp27816517p27828192.html
> Sent from the Struts - User mailing list archive at Nabble.com.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
 		 	   		  
_________________________________________________________________
Hotmail: Free, trusted and rich email service.
http://clk.atdmt.com/GBL/go/201469228/direct/01/

Re: Cannot find bean: "bookList" in any scope

Posted by tesla <fa...@hotmail.com>.
thx for helping but now when i run the application i see an empty page i
can't see books which i retrive from my database i guess my arraylist is
empty why it is??
-- 
View this message in context: http://old.nabble.com/Cannot-find-bean%3A-%22bookList%22-in-any-scope-tp27816517p27828192.html
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Cannot find bean: "bookList" in any scope

Posted by st...@gmail.com.
You have bookList and listBook.  Change one of them.

On Sun, Mar 7, 2010 at 8:25 PM, tesla <fa...@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-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>