You are viewing a plain text version of this content. The canonical link for it is here.
Posted to taglibs-user@tomcat.apache.org by "Popova, Marina" <ma...@t-t.com> on 2003/10/21 19:22:05 UTC

EL expressions are not evaluated

Hi, 
Sorry if this question was asked already...
  I am trying to write a simple test web application using JSTL and
encountered the following problem:
JSTL core tags are working fine (like <c:out ...>, <c:forEach...>) but the
EL expressions are not evaluated. I do use the c.tld file - it is in my
app's WEB-INf directory. Below is a simple test page that demonstrates the
problem:

<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
<html>
<head>
  <title>JSTL WISS Preview</title>
</head>
<body bgcolor="#FFFFFF">

 <jsp:useBean id="directory"
   class="test_wiss_JSTL.WISSDirectoryDataBean" />

  <br>
  Total number of Files (JSTL): <c:out value="${directory.totalNumFiles}"/>
  <br>
  Total number of Files (JSP):
  <jsp:getProperty name="directory" property="totalNumFiles"/>
  <br>

  <c:forEach var="i" begin="1" end="5">
   <c:out value="${i}"/><br>
  </c:forEach>

  <c:forEach var="file" items="${directory.fileList}">
    <c:out value="${file}"/><br>
  </c:forEach>

</body>
</html>

The result (in the browser) is:

Total number of Files (JSTL): ${directory.totalNumFiles} 
Total number of Files (JSP): 2 
${i}
${i}
${i}
${i}
${i}
${file}

So, as you can see, the <c:xxx> tags work correctly , the usual JSP tags
work correctly also and the bean's totalNumFiles value is shown correctly
too, but when I try to show the same value using the EL expression
(${directory.totalNumFiles} ) - it does not work. Nor does a simple integer
value ${i} - not a bean's property...

It seems I'm missing something very obvious - just cannot see it just yet.
Any ideas?

I use Tomcat5.0.12. I did try to include the JSTL's jar files (standard.jar
and jstl.jar)  into my web application's WEB-INF/lib directory, even though
they are in the $CATALINA/commons/lib - it did not help. 

Thanks,
Marina

---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org


Re: EL expressions are not evaluated

Posted by Manos Papantoniou <ma...@h-infinity.co.uk>.
Try adding 

<?xml version="1.0" ?>

<web-app version="2.4" 

xmlns="http://java.sun.com/xml/ns/j2ee" 

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 

xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee web-app_2_4.xsd">

at the top of your web.xml. If you don't tell tomcat this is a 2.4 version document it will not try evaluating EL expressions.

Also, don't double-include libs that are already in tomcat/common/lib in your WEB-INF/lib since it can cause problems. There is no need for it either. If you are using an IDE you might have to include just the path to those libraries in the project settings

Manos



  ----- Original Message ----- 
  From: Popova, Marina 
  To: 'taglibs-user@jakarta.apache.org' 
  Sent: Tuesday, October 21, 2003 6:22 PM
  Subject: EL expressions are not evaluated


  Hi, 
  Sorry if this question was asked already...
    I am trying to write a simple test web application using JSTL and
  encountered the following problem:
  JSTL core tags are working fine (like <c:out ...>, <c:forEach...>) but the
  EL expressions are not evaluated. I do use the c.tld file - it is in my
  app's WEB-INf directory. Below is a simple test page that demonstrates the
  problem:

  <%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
  <html>
  <head>
    <title>JSTL WISS Preview</title>
  </head>
  <body bgcolor="#FFFFFF">

   <jsp:useBean id="directory"
     class="test_wiss_JSTL.WISSDirectoryDataBean" />

    <br>
    Total number of Files (JSTL): <c:out value="${directory.totalNumFiles}"/>
    <br>
    Total number of Files (JSP):
    <jsp:getProperty name="directory" property="totalNumFiles"/>
    <br>

    <c:forEach var="i" begin="1" end="5">
     <c:out value="${i}"/><br>
    </c:forEach>

    <c:forEach var="file" items="${directory.fileList}">
      <c:out value="${file}"/><br>
    </c:forEach>

  </body>
  </html>

  The result (in the browser) is:

  Total number of Files (JSTL): ${directory.totalNumFiles} 
  Total number of Files (JSP): 2 
  ${i}
  ${i}
  ${i}
  ${i}
  ${i}
  ${file}

  So, as you can see, the <c:xxx> tags work correctly , the usual JSP tags
  work correctly also and the bean's totalNumFiles value is shown correctly
  too, but when I try to show the same value using the EL expression
  (${directory.totalNumFiles} ) - it does not work. Nor does a simple integer
  value ${i} - not a bean's property...

  It seems I'm missing something very obvious - just cannot see it just yet.
  Any ideas?

  I use Tomcat5.0.12. I did try to include the JSTL's jar files (standard.jar
  and jstl.jar)  into my web application's WEB-INF/lib directory, even though
  they are in the $CATALINA/commons/lib - it did not help. 

  Thanks,
  Marina

  ---------------------------------------------------------------------
  To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
  For additional commands, e-mail: taglibs-user-help@jakarta.apache.org