Yeah, I figured it out. Thanks a lot for the response.

Hunter

> From: Martin Cooper <[EMAIL PROTECTED]>
> Reply-To: "Tag Libraries Users List" <[EMAIL PROTECTED]>
> Date: Mon, 10 Feb 2003 23:00:19 -0800 (PST)
> To: Tag Libraries Users List <[EMAIL PROTECTED]>
> Subject: Re: foreach Problem - Not iterating like expected...
> 
> 
> 
> On Mon, 10 Feb 2003, Hunter Hillegas wrote:
> 
>> I have the following code:
>> 
>> <%
>>     System.out.println("Start Page: " + startPage); //DEBUG
>>     System.out.println("End Page: " + endPage); //DEBUG
>> %>
>> 
>> <c:forEach begin="${startPage}" end="${endPage}">
>>     <%
>>         System.out.println("Looping..."); //DEBUG
>>     %>
>> </c:forEach>
>> 
>> When I run this code, I get the following values printed out for start and
>> end:
>> 
>> Start Page: 0
>> End Page: 42
>> 
>> But, the code only loops through one time, instead of looping all the times
>> I would expect... Shouldn't it be counting up through all iterations between
>> 0 and 42?
> 
> Nope. You are making a common mistake - assuming that scripting variables
> and scoped attributes are the same thing.
> 
> The 'startPage' and 'endPage' variables that you are displaying using
> System.out.println() are scripting variables. Scripting variables are not
> visible to the regular JSTL tags - those tags obtain their attribute
> values from scoped attributes (e.g. request or session attributes)
> instead.
> 
> To have your loop behave correctly, you'll need to set startPage and
> endPage as scoped attributes instead of scripting variables.
> 
> --
> Martin Cooper
> 
> 
>> 
>> If I replace the begin and end with 0 and 42 like this:
>> 
>> <c:forEach begin="0" end="42">
>>     <%
>>         System.out.println("Looping..."); //DEBUG
>>     %>
>> </c:forEach>
>> 
>> Then it loops as I would expect.
>> 
>> What am I doing wrong?
>> 
>> Thanks,
>> Hunter
>> 
>> 
>> ---------------------------------------------------------------------
>> 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]


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

Reply via email to