1 Reply Latest reply on Jun 27, 2007 5:15 PM by Frank Langelage

    foreach (= advanced for) in JSPS

    Hans-Michael Rupp Novice

      Hallo!

      I have tried to use foreach (= advanced for) in JSPs

      <% for (Order order: orders.getOrders()) { %>
      <tr><td><%= order.getItem() %></td><td><%= order.getPrice() %></td><td><%= order.getNumber() %></td></tr>
      <% } %>


      This works fine with Tomcat 5.5.23, however when deploying the same war to JBoss 4.0.5 GA I get the following exception
      org.apache.jasper.JasperException: Unable to compile class for JSP

      An error occurred at line: 19 in the jsp file: /test.jsp
      Generated servlet error:
      Syntax error, 'for each' statements are only available if source level is 5.0

      An error occurred at line: 19 in the jsp file: /test.jsp
      Generated servlet error:
      Can only iterate over an array or an instance of java.lang.Iterable
      org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:512)
      org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377)
      org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
      org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
      org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)

      I thought JBoss uses Tomcat 5.5 as a Servlet container. So why this difference?

      Thanx,

      Hans