You are getting the error because you have not defined a scripting
variable for the threadbean.
Simple way of doing that is using the bean:define tag

<bean:define id="threadbean" name="ThreadBeans" toScope="request" /> 

Please let me know if there is any problem in using this
Thanks,
Satish

-----Original Message-----
From: Caroline Jen [mailto:[EMAIL PROTECTED] 
Sent: Sunday, June 13, 2004 5:30 AM
To: Struts Users Mailing List
Subject: RE: Cannot Find Bean in Any Scope


Sorry for not being clear about the problem that I
have.

1. I have a JavaBean, which is named as ThreadBean
with lots of properties.

2. My ListThread.java class extends Action.  In that
class, I created a collection of beans.  Each of those
beans is a ThreadBean.

3. By the end of the ListThread.java, I passed those
beans to my JSP in the request scope this way:

      request.setAttribute( "ThreadBeans", beans );

4. In my JSP (I did import the ThreadBean), I have

<%
Collection threadRows = ( Collection
)request.getAttribute( "ThreadBeans" );

int odd = 0;
   Iterator iterator = threadRows.iterator();
   while( iterator.hasNext() ) 
   {
      odd = ( odd + 1 )%2;
      ThreadBean threadBean = ( ThreadBean
)iterator.next();

      .....
   }
%>

5. when I tried to write out the properties; for
example:

<%=threadBean.getSender()%> <%=threadBean.getThreadReplyCount()%>
<%=threadBean.getThreadViewCount()%>
......

I got the error message:

----- Root Cause -----
javax.servlet.ServletException: Cannot find bean
threadBean in any scope





--- "CRANFORD, CHRIS" <[EMAIL PROTECTED]>
wrote:
> 
> -- If you want to specify a new bean instance, use
> this:
> <bean:define id="threadBean" 
> type="org.MyOrg.MyProj.message.ThreadBean" /> <bean:write 
> name="threadBean" property="sender"/> <bean:write name="threadBean"
> property="threadReplyCount"/>
> <bean:write name="threadBean"
> property="threadViewCount"/>
> 
> -- If the bean already exists
> <bean:define id="threadBean" name"ThreadBean" 
> type="org.MyOrg.MyProj.message.ThreadBean"/>
> <bean:write name="threadBean" property="sender"/>
> ....
> 
> I think this is right ..
> Chris
> 
> -----Original Message-----
> From: Caroline Jen [mailto:[EMAIL PROTECTED]
> Sent: Saturday, June 12, 2004 7:28 PM
> To: [EMAIL PROTECTED]
> Subject: Cannot Find Bean in Any Scope
> 
> 
> I am using the Struts framework.  I have a JSP,
> which
> imports a JavaBean "ThreadBean".  Therefore, in the
> beginning of my JSP, in addition to
> 
> <%@ taglib uri="/tags/struts-html" prefix="html" %>
> <%@ taglib uri="/tags/struts-bean" prefix="bean" %>
> <%@ taglib uri="/tags/struts-logic" prefix="logic"
> %>
> <%@ taglib uri="/tags/tiles" prefix="tiles" %>
> <%@ taglib uri="/tags/request" prefix="req" %>
> 
> I have
> 
> <%@ page
> import="org.MyOrg.MyProj.message.ThreadBean"
> %>
> 
> In my JSP, I try to write out the properties of this JavaBean; for 
> example:
> 
>   <%=threadBean.getSender()%>
>   <%=threadBean.getThreadReplyCount()%>
>   <%=threadBean.getThreadViewCount()%>
> 
> I got the error message:
> 
> ----- Root Cause -----
> javax.servlet.ServletException: Cannot find bean
> threadBean in any scope
> 
> What is the correct way to do it?
> 
> 
> 
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam
> protection around
> http://mail.yahoo.com 
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> [EMAIL PROTECTED]
> For additional commands, e-mail:
> [EMAIL PROTECTED]
> 
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> [EMAIL PROTECTED]
> For additional commands, e-mail:
> [EMAIL PROTECTED]
> 
> 



        
                
__________________________________
Do you Yahoo!?
Friends.  Fun.  Try the all-new Yahoo! Messenger.
http://messenger.yahoo.com/ 

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to