Problems with JSTL forEach in JSF 2

14,559

Solution 1

What about standard.jar?

Do you have both JARs in WEB-INF/lib?

Solution 2

I think you are missing a JSTL-api jar.

Classname search on sonatype's nexus returned this maven dependency:

<dependency>
  <groupId>javax.servlet</groupId>
  <artifactId>jstl</artifactId>
  <version>1.1.2</version>
</dependency>

You can download it from this page if you don't use maven.

You can also use Findjar.com to find occurrences of the class.

Solution 3

If memory serves me right the JSTL core uses EL which has syntax like this ${} rather than #{}.

Share:
14,559
Marcel Menz
Author by

Marcel Menz

Updated on June 19, 2022

Comments

  • Marcel Menz
    Marcel Menz almost 2 years

    Hi I got the following code:

    <?xml version="1.0" encoding="UTF-8" ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0    
    Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.prime.com.tr/ui"
      xmlns:c="http://java.sun.com/jsp/jstl/core"
    >
    
    <h:body>
     <c:forEach items="#{backingBean.personList}" var="person">
       <h:outputText value="#{person.name}" />
     </c:forEach>
    </h:body>
    </html>    
    

    This fails with:

     java.lang.ClassNotFoundException: javax.servlet.jsp.jstl.core.LoopTagStatus
    

    I use jstl-impl-1.2.jar. Does anyone could help me on this one? Thanks

    Marcel

  • Marcel Menz
    Marcel Menz over 13 years
    That was quick. I used the implementation 1.2 from jstl.dev.java.net/download.html which offers no standard.jar. I now tried the 1.1.2 jakarta version and it works. Thanks Marcel
  • BalusC
    BalusC over 13 years
    If that did fix the problem, then it means that your web.xml was decared as servlet 2.4 or older instead of servlet 2.5 or newer. Try to declare the web.xml to max servlet version as supported by servletcontainer.