jstl does not work with foreach

Discussion in 'Java' started by Quick Function, Jul 14, 2004.

  1. I am testing jstl, here is my jsp:

    <%@ page language="java" contentType="text/html" %>
    <%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
    <html>
    <body>
    <table border=1>
    <tr>
    <th>Value</th>
    <th>Square</th>
    </tr>
    <c:forEach var="x" begin="0" end="4" step="2">
    <tr>
    <td><c:eek:ut value="${x}"/></td>
    <td><c:eek:ut value="${x * x}"/></td>
    </tr>
    </c:forEach>
    </table>

    </body>
    </html>

    But the output in web broswer is :

    Value Square
    ${x} ${x * x}
    ${x} ${x * x}
    ${x} ${x * x}


    Why?

    Thanks,

    qq
    Quick Function, Jul 14, 2004
    #1
    1. Advertising

  2. Quick Function

    Murray Guest

    > But the output in web broswer is :
    >
    > Value Square
    > ${x} ${x * x}
    > ${x} ${x * x}
    > ${x} ${x * x}
    >
    >
    > Why?
    >
    > Thanks,
    >
    > qq


    Your example works fine for me (using Tomcat 5). Sounds like a configuration
    issue. Is it possible that you're using the core_rt library instead of the
    standard EL core?
    Murray, Jul 14, 2004
    #2
    1. Advertising

  3. Quick Function

    Murray Guest

    "Murray" <> wrote in message
    news:40f51199$0$25458$...
    > > But the output in web broswer is :
    > >
    > > Value Square
    > > ${x} ${x * x}
    > > ${x} ${x * x}
    > > ${x} ${x * x}
    > >
    > >
    > > Why?
    > >
    > > Thanks,
    > >
    > > qq

    >
    > Your example works fine for me (using Tomcat 5). Sounds like a

    configuration
    > issue. Is it possible that you're using the core_rt library instead of the
    > standard EL core?
    >
    >


    Does something as simple as <c:eek:ut value="${1 + 2}"/> work?
    Murray, Jul 14, 2004
    #3
  4. "Murray" <> wrote in message news:<40f51199$0$25458$>...
    > > But the output in web broswer is :
    > >
    > > Value Square
    > > ${x} ${x * x}
    > > ${x} ${x * x}
    > > ${x} ${x * x}
    > >
    > >
    > > Why?
    > >
    > > Thanks,
    > >
    > > qq

    >
    > Your example works fine for me (using Tomcat 5). Sounds like a configuration
    > issue. Is it possible that you're using the core_rt library instead of the
    > standard EL core?


    I am using tomcat 5 too.

    Here is my web.xml:

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web
    Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
    <web-app>
    <taglib>
    <taglib-uri>http://java.sun.com/jstl/core</taglib-uri>
    <taglib-location>/WEB-INF/c.tld</taglib-location>
    </taglib>
    </web-app>

    I copy all tlb files from C:\jakarta-taglibs\standard\tld to my
    WEB-INF and jstl.har and standard.jar to my WEB-INF\lib.
    Quick Function, Jul 14, 2004
    #4
  5. "Murray" <> wrote in message news:<40f514ab$0$18669$>...
    > "Murray" <> wrote in message
    > news:40f51199$0$25458$...
    > > > But the output in web broswer is :
    > > >
    > > > Value Square
    > > > ${x} ${x * x}
    > > > ${x} ${x * x}
    > > > ${x} ${x * x}
    > > >
    > > >
    > > > Why?
    > > >
    > > > Thanks,
    > > >
    > > > qq

    > >
    > > Your example works fine for me (using Tomcat 5). Sounds like a

    > configuration
    > > issue. Is it possible that you're using the core_rt library instead of the
    > > standard EL core?
    > >
    > >

    >
    > Does something as simple as <c:eek:ut value="${1 + 2}"/> work?


    No it doesn't. It print out "${1 + 2}";

    I think it is some configuration. Here is my web.xml

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web
    Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
    <web-app>
    <taglib>
    <taglib-uri>/WEB-INF/c.tld</taglib-uri>
    <taglib-location>/WEB-INF/c.tld</taglib-location>
    </taglib>
    <taglib>
    <taglib-uri>/WEB-INF/c.tld</taglib-uri>
    <taglib-location>/WEB-INF/c.tld</taglib-location>
    </taglib>
    <taglib>
    <taglib-uri>/WEB-INF/fmt.tld</taglib-uri>
    <taglib-location>/WEB-INF/fmt.tld</taglib-location>
    </taglib>
    </web-app>

    I copied all tld files download to WEB-INF and jstl.jar and
    standard.jar to WEB-INF/lib.
    Quick Function, Jul 14, 2004
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jack

    JSTL with Struts c:forEach

    Jack, Aug 5, 2003, in forum: Java
    Replies:
    2
    Views:
    16,418
    VisionSet
    Aug 5, 2003
  2. NP
    Replies:
    0
    Views:
    5,271
  3. Andrea Desole

    JSF version of JSTL forEach?

    Andrea Desole, Dec 7, 2004, in forum: Java
    Replies:
    3
    Views:
    13,539
    masterprogrammer
    Aug 21, 2006
  4. Replies:
    2
    Views:
    1,913
    willirl
    Jan 14, 2005
  5. Bob Rivers

    JSTL forEach

    Bob Rivers, Jan 28, 2005, in forum: Java
    Replies:
    3
    Views:
    20,515
    Tim Slattery
    Jan 31, 2005
Loading...

Share This Page