You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Curtis Taylor <c....@verizon.net> on 2004/04/10 03:08:24 UTC

Re: [slightly OT] Any advice for 'jsp.error.useBean.duplicate' ?

You're creating the bean "status" in the varStatus declaration in your c:forEach 
action. It's in scope in the loop as "status" already, so you don't need to 
re-initialize it. You can access its attributes inside your loop:

<c:out value="$status.begin" />
<c:out value="$status.count" />
<c:out value="$status.index" />

...etc.

Just curious; what're you trying to do inside the loop?

Curtis
--
c dot tee at verizon dot net


bOOyah wrote:
> It's killing me.  Here's the snippet:
> 
> [ServletException in:/pages/editscheduledetails.jsp]
> /pages/editscheduledetails.jsp(276,6) jsp.error.useBean.duplicate'
> org.apache.jasper.JasperException: /pages/editscheduledetails.jsp(276,6)
> 
> My assumption in that the Jasper compiler thinks I have attempted to use 
> a bean multiple times in the same scope or something.
> 
> 
> Here's the only piece of that JSP that uses a bean:
> 
> Line 276:
> 
> <c:forEach items="${ScheduleDetailsForm.eventsList}"
>            var="event" varStatus="status">
>   <jsp:useBean id="status"
>                type="javax.servlet.jsp.jstl.core.LoopTagStatus"/>
> ...
> 
> 
> If I change "status" to "qwerty" it all works fine!  The JSP books say 
> that the 'varStatus' variable is local to the 'c:forEach' loop!  How can 
> I be declaring duplicate beans?  I even added a scope="page" to the 
> 'useBean' clause, but it made no difference.
> 
> I'm not explicitly including other JSPs in this JSP...I'm using Tiles 
> and Struts.
> 
> Google only returns very scant info about 'jsp.error.useBean.duplicate' :-(
> 
> 
> Thanks for any help.
> 


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


Re: [slightly OT] Any advice for 'jsp.error.useBean.duplicate' ?

Posted by bOOyah <bo...@nowhere.org>.
Curtis Taylor wrote:

> You're creating the bean "status" in the varStatus declaration in your 
> c:forEach action. It's in scope in the loop as "status" already, so you 
> don't need to re-initialize it. You can access its attributes inside 
> your loop:
> 
> <c:out value="$status.begin" />
> <c:out value="$status.count" />
> <c:out value="$status.index" />
> 
> ...etc.
*sigh*  You are, of course, correct.  I could have sworn I tried that. 
I certainly swore.

> Just curious; what're you trying to do inside the loop?
The old 'alternating-table-row-color' trick.

<c:forEach items="${ScheduleDetailsForm.eventsList}"
         var="event"
         varStatus="status">

   <c:choose>
     <c:when test="${status.count%2 == 0}">
       <%-- set style for EVEN rows --%>
   <c:otherwise>
       <%-- set style for ODD rows --%>
   </c:choose>

</c:forEach


No doubt there's a better way of doing that too.

Many thanks Curtis.

-- 
bOOyah


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