0

I was following this jstl tutorial.
I am trying to print values in a c:forEach loop, but the value for i is not being printed.

My code:

<%--
    Created by IntelliJ IDEA.
    User: Jaideep Shekhar
    Date: 25.11.2020
    Time: 15:00
    To change this template use File | Settings | File Templates
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix = "c" uri = "http://java.sun.com/jsp/jstl/core" %>
<html>
<body>
    <c:forEach var="i" begin="0" end="10">
        <h1><c:out value="${i}"/></h1>
    </c:forEach>
</body>
</html>

The output is:

${i}
${i}
${i}
${i}
${i}
${i}
${i}
${i}
${i}
${i}
${i}

Any help appreciated!

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Jaideep Shekhar
  • 808
  • 2
  • 7
  • 21
  • Just replace this <%@ taglib uri = "http://java.sun.com/jsp/jstl/core" prefix = "c" %> – Anuresh Verma Nov 28 '20 at 14:05
  • @anuresh does it work for you? Because this references a file, and not a url. – Jaideep Shekhar Nov 28 '20 at 14:09
  • JSTL is working perfectly fine. If it didn't work fine, then you wouldn't have seen anything printed at all, for sure not 10 times exactly as instructed to your ``. It would have remained hidden in the generated HTML output. It's just EL which is in turn not working. – BalusC Nov 28 '20 at 18:29
  • @BalusC the theory is all well and fine, but is there a solution? I know JSTL is working, but `c:out` is not, which is why I gave you the output. – Jaideep Shekhar Nov 29 '20 at 11:24
  • See link to duplicate question in top of your question. The answer is over there. – BalusC Nov 29 '20 at 11:28
  • @BalusC Aah, I see that there is an incorrect ` ` there. Removed, and it works. Do I delete the question? – Jaideep Shekhar Nov 29 '20 at 11:33

0 Answers0