You are viewing a plain text version of this content. The canonical link for it is here.
Posted to taglibs-user@tomcat.apache.org by Thilo Schwidurski <th...@web.de> on 2003/08/27 15:34:01 UTC

forEach => Exception javax/servlet/jsp/jstl/core/LoopTagSupport

Hi,

This...

<c:out value="${stock.test[0]}"></c:out>

...works fine (with stock.test is of class ArrayList).


This...

<c:forEach var="i" begin="3" end="20" step="3">
    <c:out value="${i}"/>,
</c:forEach>

...and this...

<c:forEach var="item" items="${stock.test}">
   <td><c:out value="${item}"/></td>
</c:forEach>

... results in:

javax.servlet.ServletException: javax/servlet/jsp/jstl/core/LoopTagSupport


So it seems that the forEach tag is kind of "broken". Does anybody have 
an idea what I am doing wrong here?
I am using jakarta-taglibs-standard-1.0.3
Where can I download the sources for 1.0.3 so that I can debug at least?

Regards,
Thilo.



Re: forEach => Exception javax/servlet/jsp/jstl/core/LoopTagSupport

Posted by Thilo Schwidurski <th...@web.de>.
Steve Raeburn wrote:
> You need to use the status variable to get the current loop index.
> 
> <c:forEach begin="3" end="20" step="3" varStatus="status">
>     <c:out value="${status.index}"/>
> </c:forEach>
> 
> Steve 
> http://www.ninsky.com/struts/

Hi Steve,
thanks for answering. Unfortunately, this does'nt solve my problem, 
which is kind of really basic.
It seems that *any* usage of forEach results in the subjects' exception.
This would'nt be so odd if "<c:out" also would fail, but it does'nt.

Regards,
Thilo.



Re: forEach => Exception javax/servlet/jsp/jstl/core/LoopTagSupport

Posted by Jason Lea <ja...@kumachan.net.nz>.
I have same set up (1.0.3 & 4.1.24) and this works.

Perhaps you should check that you really do have Standard 1.0.3 and are 
referencing it in your web.xml.

The timestamp on standard.jar & jstl.jar should 2003-02-19 5:06pm


Thilo Schwidurski wrote:

> Kris Schneider wrote:
> 
>> Not really sure why it's not working for you, but the following works 
>> just fine
>> with Standard 1.0.3 on Tomcat 4.1.24:
> 
> 
> Thanks, Kris.
> 
> Standard 1.0.3 on Tomcat 4.1.24 is also my setup.
> 
> [your example code]
> 
> My problem is still, that *already* the following less "sophisticated" 
> code fails:
> 
> <c:forEach var="i" begin="3" end="20" step="3">
>    <c:out value="${i}"/>
> </c:forEach>
> 
> Well, I am back using struts' logic:iterate now.
> This is really frustrating... :-/
> 
> Thanks,
> Thilo.
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: taglibs-user-help@jakarta.apache.org
> 
> 


-- 
Jason Lea


RE: forEach => Exception javax/servlet/jsp/jstl/core/LoopTagSupport

Posted by Steve Raeburn <st...@ninsky.com>.
OK. I was sure I tried that a while ago and it didn't work for me. 
Just checked it and, as you said, it does work.

Thanks

Steve 

> -----Original Message-----
> From: Serge Knystautas [mailto:sergek@lokitech.com]
> Sent: August 28, 2003 7:18 AM
> To: Tag Libraries Users List
> Subject: Re: forEach => Exception
> javax/servlet/jsp/jstl/core/LoopTagSupport
> 
> 
> No, using var to get the index value in a non-items forEach usage is 
> perfectly legal.  Kris's almost exact same example is in the JSTL spec 
> 6.1.4.  What he's doing should work.
> 
> But Kris, the JSTL is designed to fast fail, rather than throw 
> exceptions.  The operating principle was to have tags fast fail whenever 
> possible (such as c:out with a null value) rather than require a lot of 
> extra typing to declare variables and handle null values and exceptions.
> 
> -- 
> Serge Knystautas
> President
> Lokitech >> software . strategy . design >> http://www.lokitech.com
> p. 301.656.5501
> e. sergek@lokitech.com
> 
> Steve Raeburn wrote:
> > You need to use the status variable to get the current loop index.
> > 
> > <c:forEach begin="3" end="20" step="3" varStatus="status">
> >     <c:out value="${status.index}"/>
> > </c:forEach>
> > 
> > Steve 
> > http://www.ninsky.com/struts/
> > 
> > 
> > 
> >>-----Original Message-----
> >>From: news [mailto:news@sea.gmane.org]On Behalf Of Thilo Schwidurski
> >>Sent: August 27, 2003 11:59 PM
> >>To: taglibs-user@jakarta.apache.org
> >>Subject: Re: forEach => Exception
> >>javax/servlet/jsp/jstl/core/LoopTagSupport
> >>
> >>
> >>Kris Schneider wrote:
> >>
> >>>Not really sure why it's not working for you, but the following 
> >>
> >>works just fine
> >>
> >>>with Standard 1.0.3 on Tomcat 4.1.24:
> >>
> >>Thanks, Kris.
> >>
> >>Standard 1.0.3 on Tomcat 4.1.24 is also my setup.
> >>
> >>[your example code]
> >>
> >>My problem is still, that *already* the following less "sophisticated" 
> >>code fails:
> >>
> >><c:forEach var="i" begin="3" end="20" step="3">
> >>    <c:out value="${i}"/>
> >></c:forEach>
> >>
> >>Well, I am back using struts' logic:iterate now.
> >>This is really frustrating... :-/
> >>
> >>Thanks,
> >>Thilo.
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: taglibs-user-help@jakarta.apache.org
> 
> 
> 


Re: forEach => Exception javax/servlet/jsp/jstl/core/LoopTagSupport

Posted by Serge Knystautas <se...@lokitech.com>.
No, using var to get the index value in a non-items forEach usage is 
perfectly legal.  Kris's almost exact same example is in the JSTL spec 
6.1.4.  What he's doing should work.

But Kris, the JSTL is designed to fast fail, rather than throw 
exceptions.  The operating principle was to have tags fast fail whenever 
possible (such as c:out with a null value) rather than require a lot of 
extra typing to declare variables and handle null values and exceptions.

-- 
Serge Knystautas
President
Lokitech >> software . strategy . design >> http://www.lokitech.com
p. 301.656.5501
e. sergek@lokitech.com

Steve Raeburn wrote:
> You need to use the status variable to get the current loop index.
> 
> <c:forEach begin="3" end="20" step="3" varStatus="status">
>     <c:out value="${status.index}"/>
> </c:forEach>
> 
> Steve 
> http://www.ninsky.com/struts/
> 
> 
> 
>>-----Original Message-----
>>From: news [mailto:news@sea.gmane.org]On Behalf Of Thilo Schwidurski
>>Sent: August 27, 2003 11:59 PM
>>To: taglibs-user@jakarta.apache.org
>>Subject: Re: forEach => Exception
>>javax/servlet/jsp/jstl/core/LoopTagSupport
>>
>>
>>Kris Schneider wrote:
>>
>>>Not really sure why it's not working for you, but the following 
>>
>>works just fine
>>
>>>with Standard 1.0.3 on Tomcat 4.1.24:
>>
>>Thanks, Kris.
>>
>>Standard 1.0.3 on Tomcat 4.1.24 is also my setup.
>>
>>[your example code]
>>
>>My problem is still, that *already* the following less "sophisticated" 
>>code fails:
>>
>><c:forEach var="i" begin="3" end="20" step="3">
>>    <c:out value="${i}"/>
>></c:forEach>
>>
>>Well, I am back using struts' logic:iterate now.
>>This is really frustrating... :-/
>>
>>Thanks,
>>Thilo.



RE: forEach => Exception javax/servlet/jsp/jstl/core/LoopTagSupport

Posted by Steve Raeburn <st...@ninsky.com>.
You need to use the status variable to get the current loop index.

<c:forEach begin="3" end="20" step="3" varStatus="status">
    <c:out value="${status.index}"/>
</c:forEach>

Steve 
http://www.ninsky.com/struts/


> -----Original Message-----
> From: news [mailto:news@sea.gmane.org]On Behalf Of Thilo Schwidurski
> Sent: August 27, 2003 11:59 PM
> To: taglibs-user@jakarta.apache.org
> Subject: Re: forEach => Exception
> javax/servlet/jsp/jstl/core/LoopTagSupport
> 
> 
> Kris Schneider wrote:
> > Not really sure why it's not working for you, but the following 
> works just fine
> > with Standard 1.0.3 on Tomcat 4.1.24:
> 
> Thanks, Kris.
> 
> Standard 1.0.3 on Tomcat 4.1.24 is also my setup.
> 
> [your example code]
> 
> My problem is still, that *already* the following less "sophisticated" 
> code fails:
> 
> <c:forEach var="i" begin="3" end="20" step="3">
>     <c:out value="${i}"/>
> </c:forEach>
> 
> Well, I am back using struts' logic:iterate now.
> This is really frustrating... :-/
> 
> Thanks,
> Thilo.
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: taglibs-user-help@jakarta.apache.org
> 
> 
> 


Re: forEach => Exception javax/servlet/jsp/jstl/core/LoopTagSupport

Posted by Thilo Schwidurski <th...@web.de>.
Kris Schneider wrote:
> Not really sure why it's not working for you, but the following works just fine
> with Standard 1.0.3 on Tomcat 4.1.24:

Thanks, Kris.

Standard 1.0.3 on Tomcat 4.1.24 is also my setup.

[your example code]

My problem is still, that *already* the following less "sophisticated" 
code fails:

<c:forEach var="i" begin="3" end="20" step="3">
    <c:out value="${i}"/>
</c:forEach>

Well, I am back using struts' logic:iterate now.
This is really frustrating... :-/

Thanks,
Thilo.



Re: forEach => Exception javax/servlet/jsp/jstl/core/LoopTagSupport

Posted by Kris Schneider <kr...@dotech.com>.
Not really sure why it's not working for you, but the following works just fine
with Standard 1.0.3 on Tomcat 4.1.24:

<%@ page contentType="text/plain" %>
<%@ page import="java.util.*" %>

<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>

<%
Object[] testData = { "0", "1", "2" };
List test = Arrays.asList(testData);

Map stock = new HashMap();
stock.put("test", test);
pageContext.setAttribute("stock", stock);
%>

<c:forEach var="i" begin="3" end="20" step="3">
    <c:out value="${i}"/>
</c:forEach>

<c:forEach var="item" items="${stock.test}">
   <c:out value="${item}"/>
</c:forEach>

Quoting Thilo Schwidurski <th...@web.de>:

> Hi,
> 
> This...
> 
> <c:out value="${stock.test[0]}"></c:out>
> 
> ...works fine (with stock.test is of class ArrayList).
> 
> 
> This...
> 
> <c:forEach var="i" begin="3" end="20" step="3">
>     <c:out value="${i}"/>,
> </c:forEach>
> 
> ...and this...
> 
> <c:forEach var="item" items="${stock.test}">
>    <td><c:out value="${item}"/></td>
> </c:forEach>
> 
> ... results in:
> 
> javax.servlet.ServletException: javax/servlet/jsp/jstl/core/LoopTagSupport
> 
> 
> So it seems that the forEach tag is kind of "broken". Does anybody have 
> an idea what I am doing wrong here?
> I am using jakarta-taglibs-standard-1.0.3
> Where can I download the sources for 1.0.3 so that I can debug at least?
> 
> Regards,
> Thilo.

-- 
Kris Schneider <ma...@dotech.com>
D.O.Tech       <http://www.dotech.com/>