Bug 20602

Summary: The body of a <c:forEach> is not executed when begin and end attributes have the same value
Product: Taglibs Reporter: Ari Savolainen <ari.savolainen>
Component: Standard TaglibAssignee: Tomcat Developers Mailing List <dev>
Status: RESOLVED FIXED    
Severity: normal    
Priority: P3    
Version: 1.0   
Target Milestone: ---   
Hardware: Other   
OS: other   

Description Ari Savolainen 2003-06-09 08:10:03 UTC
The following jsp prints nothing for the first <c:forEach> loop
but "1 2" for the second.

<%@ taglib uri="/WEB-INF/c.tld" prefix="c"  %>

<html>
    <head>
        <title>Test</title>
    </head>
    <body>
        <c:forEach begin="1" end="1" varStatus="loop" >
            <c:out value="${loop.index}" />
        </c:forEach><br />

        <c:forEach begin="1" end="2" varStatus="loop" >
            <c:out value="${loop.index}" />
        </c:forEach><br />
    </body>
</html>
Comment 1 Pierre Delisle 2003-06-18 22:02:12 UTC
Works for me using JSTL 1.0.3.
Comment 2 Ari Savolainen 2003-08-05 09:10:01 UTC
The expected result of the jsp would be:
1
1 2

The actual result was (even in JSTL 1.0.3):

1 2
Comment 3 Felipe Leme 2003-08-22 04:44:26 UTC
Hi Ari,

I tested it on my laptop (running Mandrake Linux, Tomcat 4.1.24 and Standandard
1.0.3) and it worked as expected. Here is the output:


<html>
    <head>
        <title>Test</title>
    </head>
    <body>
        
            1
        <br />

        
            1
        
            2
        <br />

    </body>
</html>
Comment 4 Felipe Leme 2003-08-22 04:45:15 UTC
PS: forgot to ask: what's the environment you are testing? Did you try on Tomcat
4.1.24?

Felipe
Comment 5 Pierre Delisle 2003-08-22 16:37:11 UTC
Re-tested, and this once again works fine for me.
Since this was also confirmed by Felipe, I'll go ahead 
and close this bug again (getting ready for a new release).

I'd however suggest the following:
  - Test with Tomcat 4.1.x and JSTL 1.0.3 to convince yourself
    that this works
  - Try to understand the difference between your environment and
    the one suggested above where this works



Comment 6 Serge Knystautas 2003-08-22 16:53:32 UTC
I'm seen the same bug in the JSTL 1.0.3 impl on Resin.  To my knowledge, Tomcat
doesn't efficiently recycle tags, so maybe there's something there.

I'll scan the code and if there's anything I think is suspicious, I'll let you know.
Comment 7 Ari Savolainen 2003-08-24 10:31:27 UTC
I was using Resin. It has its own implementation of
javax.servlet.jsp.jstl.core.LoopTagSupport. When I forced the use of jakarta
implementation of that class all worked fine.