You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by gbattine <gb...@alice.it> on 2008/12/07 17:39:33 UTC

Cannot find bean in any scope

Hello guys,
I'm newbie of Struts, please help me.
I've an action that calls some business logic, retrieve a a list and set it
into request, calling later a jsp, in which I try to show this list through
iterate tag.

this is jsp to show list

<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"%> 
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html"%> 
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
        <h2>Ricerca film</h2>
        <table border="1">
<thead>
<tr>
<th>Titolo</th>
<th>Regia</th>
<th>Sceneggiatura</th>
</tr>
</thead>
<tbody>
    <logic:iterate id="dvds" name="dvds" type="bean.DVD">
        
     <tr>
         <td><bean:write name="DVD" property="titolo"/></td>
         <td><bean:write name="DVD" property="regia"/></td>
         <td><bean:write name="DVD" property="sceneggiatura"/></td>
         
    </tr>   
        
    </logic:iterate>

this is action that pass to list a list of dvds
Collection c = new ArrayList();
        try {
            c = manager.getAll();
                    } catch (DAOException e) {
            String message = "DVDs could not be listed";
            errors.add("label", new ActionError("error.listfailed"));
            saveErrors(request, errors);
            return (mapping.findForward("error"));


        }
session.setAttribute("dvds", c);


besides dvd (shown in jsp) is a bean to show each item of dvds list.
Instead of show jsp with list of dvd I've this error:

javax.servlet.ServletException: javax.servlet.jsp.JspException: Cannot find
bean: "DVD" in any scope

How can I solve it?
please help me, 
Thanks


-- 
View this message in context: http://www.nabble.com/Cannot-find-bean-in-any-scope-tp20882790p20882790.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 in any scope

Posted by Dimitar Vlasev <vl...@gmail.com>.
1. Try this (I cite these tags on memory so excuse me if I'm not right
with the tag names)
<logic:present name="dvds"> The dvd list is present  </logic:present>
<logic:notPresent bean="dvds"> The dvd list is NOT present </logic:notPresent>

2. If the dvd list is not present try to set a simple string bean into
the request and include it in the page you're forwarding to
<bean:write name="simple_string"/>

Regards,
Dimitar Vlasev

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


Re: Cannot find bean in any scope

Posted by Nils-Helge Garli Hegvik <ni...@gmail.com>.
Do you have any null values in your collection? The only way I could
reproduce something similar was if I added "null" to the collection.

Nils-H

On Mon, Dec 8, 2008 at 11:43 AM, gbattine <gb...@alice.it> wrote:
>
> Hi,
> thanks very much for your help.
> I understood your explanation but I didn't solve.
> Now I did:
>
> <logic:iterate id="DVD" name="dvds" type="bean.DVD">
>    <tr>
>         <td><bean:write name="DVD" property="titolo"/></td>
>         <td><bean:write name="DVD" property="regia"/></td>
>         <td><bean:write name="DVD" property="sceneggiatura"/></td>
>    </tr>
> </logic:iterate>
>
> but I still have:
>
> javax.servlet.ServletException: javax.servlet.jsp.JspException: Cannot find
> bean: "DVD" in any scope
>
> I'm missing something?
> Thanks
>
>
>
>
>
> Nils-Helge Garli wrote:
>>
>> From the taglib reference for "iterate" [1]:
>>
>> id - The name of a page scope JSP bean that will contain the current
>> element of the collection on each iteration, if it is not null.
>>
>> In your example, you have used id="dvds" which means that you would
>> have to use <bean:write name="dvds" .... instead of name="DVD".
>>
>> Nils-H
>>
>> [1] -
>> http://struts.apache.org/1.3.8/struts-taglib/tagreference.html#logic:iterate
>>
>> On Sun, Dec 7, 2008 at 5:39 PM, gbattine <gb...@alice.it> wrote:
>>>
>>> Hello guys,
>>> I'm newbie of Struts, please help me.
>>> I've an action that calls some business logic, retrieve a a list and set
>>> it
>>> into request, calling later a jsp, in which I try to show this list
>>> through
>>> iterate tag.
>>>
>>> this is jsp to show list
>>>
>>> <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"%>
>>> <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html"%>
>>> <html>
>>>    <head>
>>>        <meta http-equiv="Content-Type" content="text/html;
>>> charset=UTF-8">
>>>        <title>JSP Page</title>
>>>    </head>
>>>    <body>
>>>        <h2>Ricerca film</h2>
>>>        <table border="1">
>>> <thead>
>>> <tr>
>>> <th>Titolo</th>
>>> <th>Regia</th>
>>> <th>Sceneggiatura</th>
>>> </tr>
>>> </thead>
>>> <tbody>
>>>    <logic:iterate id="dvds" name="dvds" type="bean.DVD">
>>>
>>>     <tr>
>>>         <td><bean:write name="DVD" property="titolo"/></td>
>>>         <td><bean:write name="DVD" property="regia"/></td>
>>>         <td><bean:write name="DVD" property="sceneggiatura"/></td>
>>>
>>>    </tr>
>>>
>>>    </logic:iterate>
>>>
>>> this is action that pass to list a list of dvds
>>> Collection c = new ArrayList();
>>>        try {
>>>            c = manager.getAll();
>>>                    } catch (DAOException e) {
>>>            String message = "DVDs could not be listed";
>>>            errors.add("label", new ActionError("error.listfailed"));
>>>            saveErrors(request, errors);
>>>            return (mapping.findForward("error"));
>>>
>>>
>>>        }
>>> session.setAttribute("dvds", c);
>>>
>>>
>>> besides dvd (shown in jsp) is a bean to show each item of dvds list.
>>> Instead of show jsp with list of dvd I've this error:
>>>
>>> javax.servlet.ServletException: javax.servlet.jsp.JspException: Cannot
>>> find
>>> bean: "DVD" in any scope
>>>
>>> How can I solve it?
>>> please help me,
>>> Thanks
>>>
>>>
>>> --
>>> View this message in context:
>>> http://www.nabble.com/Cannot-find-bean-in-any-scope-tp20882790p20882790.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
>>
>>
>>
>
> --
> View this message in context: http://www.nabble.com/Cannot-find-bean-in-any-scope-tp20882790p20893064.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 in any scope

Posted by gbattine <gb...@alice.it>.
Hi,
thanks very much for your help.
I understood your explanation but I didn't solve.
Now I did:

<logic:iterate id="DVD" name="dvds" type="bean.DVD">
    <tr>
         <td><bean:write name="DVD" property="titolo"/></td>
         <td><bean:write name="DVD" property="regia"/></td>
         <td><bean:write name="DVD" property="sceneggiatura"/></td>
    </tr>   
</logic:iterate>

but I still have:

javax.servlet.ServletException: javax.servlet.jsp.JspException: Cannot find
bean: "DVD" in any scope

I'm missing something?
Thanks





Nils-Helge Garli wrote:
> 
> From the taglib reference for "iterate" [1]:
> 
> id - The name of a page scope JSP bean that will contain the current
> element of the collection on each iteration, if it is not null.
> 
> In your example, you have used id="dvds" which means that you would
> have to use <bean:write name="dvds" .... instead of name="DVD".
> 
> Nils-H
> 
> [1] -
> http://struts.apache.org/1.3.8/struts-taglib/tagreference.html#logic:iterate
> 
> On Sun, Dec 7, 2008 at 5:39 PM, gbattine <gb...@alice.it> wrote:
>>
>> Hello guys,
>> I'm newbie of Struts, please help me.
>> I've an action that calls some business logic, retrieve a a list and set
>> it
>> into request, calling later a jsp, in which I try to show this list
>> through
>> iterate tag.
>>
>> this is jsp to show list
>>
>> <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"%>
>> <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html"%>
>> <html>
>>    <head>
>>        <meta http-equiv="Content-Type" content="text/html;
>> charset=UTF-8">
>>        <title>JSP Page</title>
>>    </head>
>>    <body>
>>        <h2>Ricerca film</h2>
>>        <table border="1">
>> <thead>
>> <tr>
>> <th>Titolo</th>
>> <th>Regia</th>
>> <th>Sceneggiatura</th>
>> </tr>
>> </thead>
>> <tbody>
>>    <logic:iterate id="dvds" name="dvds" type="bean.DVD">
>>
>>     <tr>
>>         <td><bean:write name="DVD" property="titolo"/></td>
>>         <td><bean:write name="DVD" property="regia"/></td>
>>         <td><bean:write name="DVD" property="sceneggiatura"/></td>
>>
>>    </tr>
>>
>>    </logic:iterate>
>>
>> this is action that pass to list a list of dvds
>> Collection c = new ArrayList();
>>        try {
>>            c = manager.getAll();
>>                    } catch (DAOException e) {
>>            String message = "DVDs could not be listed";
>>            errors.add("label", new ActionError("error.listfailed"));
>>            saveErrors(request, errors);
>>            return (mapping.findForward("error"));
>>
>>
>>        }
>> session.setAttribute("dvds", c);
>>
>>
>> besides dvd (shown in jsp) is a bean to show each item of dvds list.
>> Instead of show jsp with list of dvd I've this error:
>>
>> javax.servlet.ServletException: javax.servlet.jsp.JspException: Cannot
>> find
>> bean: "DVD" in any scope
>>
>> How can I solve it?
>> please help me,
>> Thanks
>>
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Cannot-find-bean-in-any-scope-tp20882790p20882790.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
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Cannot-find-bean-in-any-scope-tp20882790p20893064.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 in any scope

Posted by Nils-Helge Garli Hegvik <ni...@gmail.com>.
>From the taglib reference for "iterate" [1]:

id - The name of a page scope JSP bean that will contain the current
element of the collection on each iteration, if it is not null.

In your example, you have used id="dvds" which means that you would
have to use <bean:write name="dvds" .... instead of name="DVD".

Nils-H

[1] - http://struts.apache.org/1.3.8/struts-taglib/tagreference.html#logic:iterate

On Sun, Dec 7, 2008 at 5:39 PM, gbattine <gb...@alice.it> wrote:
>
> Hello guys,
> I'm newbie of Struts, please help me.
> I've an action that calls some business logic, retrieve a a list and set it
> into request, calling later a jsp, in which I try to show this list through
> iterate tag.
>
> this is jsp to show list
>
> <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"%>
> <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html"%>
> <html>
>    <head>
>        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
>        <title>JSP Page</title>
>    </head>
>    <body>
>        <h2>Ricerca film</h2>
>        <table border="1">
> <thead>
> <tr>
> <th>Titolo</th>
> <th>Regia</th>
> <th>Sceneggiatura</th>
> </tr>
> </thead>
> <tbody>
>    <logic:iterate id="dvds" name="dvds" type="bean.DVD">
>
>     <tr>
>         <td><bean:write name="DVD" property="titolo"/></td>
>         <td><bean:write name="DVD" property="regia"/></td>
>         <td><bean:write name="DVD" property="sceneggiatura"/></td>
>
>    </tr>
>
>    </logic:iterate>
>
> this is action that pass to list a list of dvds
> Collection c = new ArrayList();
>        try {
>            c = manager.getAll();
>                    } catch (DAOException e) {
>            String message = "DVDs could not be listed";
>            errors.add("label", new ActionError("error.listfailed"));
>            saveErrors(request, errors);
>            return (mapping.findForward("error"));
>
>
>        }
> session.setAttribute("dvds", c);
>
>
> besides dvd (shown in jsp) is a bean to show each item of dvds list.
> Instead of show jsp with list of dvd I've this error:
>
> javax.servlet.ServletException: javax.servlet.jsp.JspException: Cannot find
> bean: "DVD" in any scope
>
> How can I solve it?
> please help me,
> Thanks
>
>
> --
> View this message in context: http://www.nabble.com/Cannot-find-bean-in-any-scope-tp20882790p20882790.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 in any scope

Posted by "Givler, Eric" <eg...@state.pa.us>.
Sorry about that...

I really think the tutorials on the Learntechnology site are better for learning struts.  They all come with downloadable war files.  Head on over to: http://www.learntechnology.net/content/main.jsp and check them out.

-----Original Message-----
From: Givler, Eric [mailto:egivler@state.pa.us]
Sent: Tuesday, December 09, 2008 11:03 AM
To: Struts Users Mailing List
Subject: RE: Cannot find bean in any scope


This sounds like one of the tutorials on Java Boutique.  Not to plug another site, but I really thought the tutorials on ________________________________________
From: gbattine [gbattine@alice.it]
Sent: Sunday, December 07, 2008 11:39 AM
To: user@struts.apache.org
Subject: Cannot find bean in any scope

Hello guys,
I'm newbie of Struts, please help me.
I've an action that calls some business logic, retrieve a a list and set it into request, calling later a jsp, in which I try to show this list through iterate tag.

this is jsp to show list

<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"%>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html"%> <html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
        <h2>Ricerca film</h2>
        <table border="1">
<thead>
<tr>
<th>Titolo</th>
<th>Regia</th>
<th>Sceneggiatura</th>
</tr>
</thead>
<tbody>
    <logic:iterate id="dvds" name="dvds" type="bean.DVD">

     <tr>
         <td><bean:write name="DVD" property="titolo"/></td>
         <td><bean:write name="DVD" property="regia"/></td>
         <td><bean:write name="DVD" property="sceneggiatura"/></td>

    </tr>

    </logic:iterate>

this is action that pass to list a list of dvds
Collection c = new ArrayList();
        try {
            c = manager.getAll();
                    } catch (DAOException e) {
            String message = "DVDs could not be listed";
            errors.add("label", new ActionError("error.listfailed"));
            saveErrors(request, errors);
            return (mapping.findForward("error"));


        }
session.setAttribute("dvds", c);


besides dvd (shown in jsp) is a bean to show each item of dvds list. Instead of show jsp with list of dvd I've this error:

javax.servlet.ServletException: javax.servlet.jsp.JspException: Cannot find
bean: "DVD" in any scope

How can I solve it?
please help me,
Thanks


--
View this message in context: http://www.nabble.com/Cannot-find-bean-in-any-scope-tp20882790p20882790.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


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


RE: Cannot find bean in any scope

Posted by "Givler, Eric" <eg...@state.pa.us>.
This sounds like one of the tutorials on Java Boutique.  Not to plug another site, but I really thought the tutorials on
________________________________________
From: gbattine [gbattine@alice.it]
Sent: Sunday, December 07, 2008 11:39 AM
To: user@struts.apache.org
Subject: Cannot find bean in any scope

Hello guys,
I'm newbie of Struts, please help me.
I've an action that calls some business logic, retrieve a a list and set it
into request, calling later a jsp, in which I try to show this list through
iterate tag.

this is jsp to show list

<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"%>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html"%>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
        <h2>Ricerca film</h2>
        <table border="1">
<thead>
<tr>
<th>Titolo</th>
<th>Regia</th>
<th>Sceneggiatura</th>
</tr>
</thead>
<tbody>
    <logic:iterate id="dvds" name="dvds" type="bean.DVD">

     <tr>
         <td><bean:write name="DVD" property="titolo"/></td>
         <td><bean:write name="DVD" property="regia"/></td>
         <td><bean:write name="DVD" property="sceneggiatura"/></td>

    </tr>

    </logic:iterate>

this is action that pass to list a list of dvds
Collection c = new ArrayList();
        try {
            c = manager.getAll();
                    } catch (DAOException e) {
            String message = "DVDs could not be listed";
            errors.add("label", new ActionError("error.listfailed"));
            saveErrors(request, errors);
            return (mapping.findForward("error"));


        }
session.setAttribute("dvds", c);


besides dvd (shown in jsp) is a bean to show each item of dvds list.
Instead of show jsp with list of dvd I've this error:

javax.servlet.ServletException: javax.servlet.jsp.JspException: Cannot find
bean: "DVD" in any scope

How can I solve it?
please help me,
Thanks


--
View this message in context: http://www.nabble.com/Cannot-find-bean-in-any-scope-tp20882790p20882790.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