27

i have the following JSP:

<%@ page contentType="text/html" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<%@ page isELIgnored="false"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title><c:out value="${it.title}"/></title>
    </head>
    <body>
        <c:forEach var="speaker" items="${it.speakers}" varStatus="stat">
            <ul>
                <li><c:out value="${speaker.person.firstName}" /> <c:out value="${speaker.person.lastName}" />, <c:out value="${speaker.person.address.city.zip}" /> <c:out value="${speaker.person.address.city.name}" /></li>
            </ul> 
        </c:forEach>
    </body>
</html>

Eclipse warns me about every instance of EL Expressions in my code:

Warning [line 10]: "value" does not support runtime expressions
Warning [line 13]: "items" does not support runtime expressions
...

this is however not true, EL gets evaluated correctly by the server.

Can anyone hint me in the right direction why eclipse is warning me about those EL expressions?

fasseg
  • 17,504
  • 8
  • 62
  • 73

3 Answers3

63

Your taglib directive imports a JSTL 1.0 taglib. It should be JSTL 1.1 instead (note the difference in URI):

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>  
axtavt
  • 239,438
  • 41
  • 511
  • 482
  • 3
    And ensure that web.xml is declared as at least Servlet 2.4 – BalusC Aug 20 '10 at 18:07
  • @BalusC I am getting this exception and it seems to be related to your comment : org.apache.jasper.JasperException: The absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved in either web.xml or the jar files deployed with this application – abbas Jul 31 '13 at 12:46
  • Can you help what I need to do? – abbas Jul 31 '13 at 12:46
  • Also appropriate jstl library should be added: jstl-1.2.jar instead of jstl.jar and standard.jar http://stackoverflow.com/questions/8257677/why-jstl-number-format-value-does-not-support-runtime-expressions – Nenad Bulatović Jul 16 '16 at 12:24
  • Thanks.. this worked for me. Is there a way to add the line `<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> ` by default to all JSP files? – tarekahf Jul 20 '17 at 15:18
4

Possible solution (found here):

Twin Libraries

The JSTL tag libraries come in two versions which differ only in the way they support the use of runtime expressions for attribute values.

In the JSTL-RT tag library, expressions are specified in the page's scripting language. This is exactly how things currently work in current tag libraries.

In the JSTL-EL tag library, expressions are specified in the JSTL expression language. An expression is a String literal in the syntax of the EL.

When using the EL tag library you cannot pass a scripting language expression for the value of an attribute. This rule makes it possible to validate the syntax of an expression at translation time.

So maybe your eclipse and the server use different tag libraries.

Andreas Dolk
  • 113,398
  • 19
  • 180
  • 268
2

try this: change this:

<%@taglib prefix="c" uri="http://java.sun.com/jstl/core"%>

to yes:

<%@taglib prefix="c" uri="http://java.sun.com/jstl/core_rt"%>

hope it works for you. I got this from www.csdn.net.

Kurt_Zhu
  • 47
  • 5
  • 2
    This is absolutely not the **right** solution. The proposed URI is from the JSTL "prototype" version. You should upgrade to *at least* JSTL 1.1. See also axtavt's answer and http://stackoverflow.com/tags/jstl/info – BalusC Nov 26 '12 at 15:44