2017  Kodetalk | Feedback | Privacy Policy | Terms | About

JSTL variables are not shown in EL

I am not sure,when I try to execute the below code I am getting the varibale name instead of the value.

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="s" uri="http://www.springframework.org/tags" %>
  <c:forEach var="index" begin="1" end="5" >
    <c:out value="${index}" />

Results displayed on the client(browser): ${index} ${index} ${index} ${index} ${index}

Please suggest!


You will face this kind of problem only when your servlet container runs at Servlet 2.3 / JSP 1.2 modus or lower, while you're using JSTL 1.1 or newer. During the change from JSTL 1.0 to 1.1, EL was moved from JSTL into JSP. That was JSP 2.0, which is part of Servlet 2.4. JSP 1.2 and older doesn't have EL bundled. JSTL 1.1 and newer doesn't have EL bundled.

You need to make sure that your web.xml root declaration conforms at least Servlet 2.4. As you're using JSP 2.1, which is part of Servlet 2.5, you're apparently targeting a Servlet 2.5 compatible container. So, make sure that your web.xml root declaration conforms Servlet 2.5:


<?xml version="1.0" encoding="UTF-8"?>
    xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_5.xsd"

    <!-- Config here. -->


Answer is