I am having trouble getting nested tags to work in Tomcat.  The code
below results in the error that follows.  If I remove the nested forEach
it works.  If I use Item <c:out value="${item}"/><br> in the first
forEach it fails.  The second .jsp code shows how it does work in
Tomcat4.  We've had the same experience with custom tags we wrote.

I would greatly appreciate any help I could get with this.  TIA.

<html>
  <body>

    <%@ taglib uri="http://java.sun.com/jsp/jstl/core"; prefix="c" %>
    
    <%@ page import="java.util.Vector" %>

    <h3>Iterating over a range</h3>
    <c:forEach var="item" begin="1" end="10">
        Item ${item}<br>
    </c:forEach>

    <% Vector v = new Vector();
        v.add("One"); v.add("Two"); v.add("Three"); v.add("Four");

        pageContext.setAttribute("vector", v);
    %>

    <h3>Iterating over a Vector</h3>

    <c:forEach items="${vector}" var="item" >
        <c:forEach items="${vector}" var="item2" >
        Item ${item} ${item2}<br>
        </c:forEach>
    </c:forEach>
  </body>
</html> 


org.apache.jasper.JasperException: Unable to compile class for JSP

An error occurred at line: 21 in the jsp file: /foreach.jsp

Generated servlet error:
    [javac] Compiling 1 source file

C:\Program Files\Apache Software Foundation\Tomcat
5.0\work\Catalina\localhost\_\org\apache\jsp\foreach_jsp.java:151:
_jspx_meth_c_forEach_2(javax.servlet.jsp.tagext.JspTag,javax.servlet.jsp
.PageContext,int[]) in org.apache.jsp.foreach_jsp cannot be applied to
(org.apache.taglibs.standard.tag.rt.core.ForEachTag,javax.servlet.jsp.Pa
geContext,int[])
          if (_jspx_meth_c_forEach_2(_jspx_th_c_forEach_1,
_jspx_page_context, _jspx_push_body_count_c_forEach_1))
              ^
1 error


        
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHa
ndler.java:127)
        
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.ja
va:351)
        
org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:415)
        org.apache.jasper.compiler.Compiler.compile(Compiler.java:458)
        org.apache.jasper.compiler.Compiler.compile(Compiler.java:439)
        
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.ja
va:553)
        
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.ja
va:291)
        
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301)
        
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:856)


<!-- This works in Tomcat4 -->
<html>
  <body>

    <%@ taglib uri="http://java.sun.com/jstl/core"; prefix="c" %>
    
    <%@ page import="java.util.Vector" %>

    <h3>Iterating over a range</h3>
    <c:forEach var="item" begin="1" end="10">
        Item <c:out value="${item}"/><br>
    </c:forEach>

    <% Vector v = new Vector();
        v.add("One"); v.add("Two"); v.add("Three"); v.add("Four");

        pageContext.setAttribute("vector", v);
    %>

    <h3>Iterating over a Vector</h3>

    <c:forEach items="${vector}" var="item" >
        <c:forEach items="${vector}" var="item2" >
        Item <c:out value="${item} ${item2}"/><br>
        </c:forEach>
    </c:forEach>
  </body>
</html> 

____________________________________________________
Dagmar C. Murray, Lead Systems Analyst/Engineer 
Purdue University
400 Centennial Mall Drive
W. Lafayette, IN 47907-2016 
E-Mail: [EMAIL PROTECTED] 



Reply via email to