aspose file tools*
The moose likes JSP and the fly likes EL expressions not evaluating Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "EL expressions not evaluating" Watch "EL expressions not evaluating" New topic
Author

EL expressions not evaluating

Bill Wied
Greenhorn

Joined: Mar 11, 2009
Posts: 9
I have created a simple JSP using JSTL (see below) and it appears that ${"expression"} expressions are not evaluating correctly. It just prints out the entire expression. I have the latest jstl.jar and standard.jar. Also the other JSTL tags seem to be working (i.e. <cut). It seems as if the EL expression is not being evaluated.

I am using Tomcat 5.5.

Any help would be appreciated.

Bill

CODE:

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

<html>
<head><title>Request header display</title></head>
<body>
<h2>Here are all the Request Headers</h2>

<%-- 'header' represents a java.util.Map type holding request-header names and values --%>
<c:forEach var="reqHead" items="${header}">

<strong><cut value=
"${reqHead.key}"/></strong>: <cut value="${reqHead.value}"/><br />

</c:forEach>


</body>
</html>

OUTPUT:

${reqHead.key}: ${reqHead.value}
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
To start, make sure that the web.xml is declared according Servlet API version 2.4.

Besides, the latest JSTL version is 1.2 which doesn't have a standard.jar. Assuming that you're using the latest JSTL version which has the both JAR's, you're talking about JSTL 1.1. The taglib URI also conforms JSTL 1.1, so this is already all fine.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61417
    
  67

Actually, your question has nothing at all to do with the JSTL.

As of JSP 2.0, the EL is processed by core JSP and has nothing at all to so with the JSTL. I've updated the subject as appropriate.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bill Wied
Greenhorn

Joined: Mar 11, 2009
Posts: 9
I got it working.

The problem seems to be that I was using the following include:
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

When I changed it to the following it worked:
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>

Any thoughts?
sandeep raj
Greenhorn

Joined: Mar 06, 2009
Posts: 10
the taglib directive you mentioned is for the jstl i.e basically the <c: /> tags , it has nothing to do with the expression language. Even if you remove the taglib directive your EL expressions should work so I am thinking that might not be the reason for the problem. .. if anyone knows more info on the reason for the problem et us know..
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61417
    
  67

The most likely cause, as Bauke pointed out, is a misconfigured deployment descriptor.
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
Bill Wied wrote:I got it working.

The problem seems to be that I was using the following include:
&lt;%@ taglib prefix=&quot;c&quot; uri=&quot;http://java.sun.com/jsp/jstl/core&quot; %&gt;

When I changed it to the following it worked:
&lt;%@ taglib prefix=&quot;c&quot; uri=&quot;http://java.sun.com/jstl/core&quot; %&gt;

Any thoughts?

So a JSTL 1.0 URI works?

Then your deployment descriptor is indeed wrong. It is likely been set to Servlet 2.2 or 2.3 instead of Servlet 2.4.

Have you taken my first reply in account at any way? Make sure that your web.xml conforms Servlet 2.4. Nothing less or more. Don't try another workarounds of which you think that it is the solution, but is actually wrong. Don't randomly try things until you understand the stuff.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61417
    
  67

Yes, you're regressing.

Take a look through the relevant entries in the JSP FAQ and set things up the correct way. Something that seems to work isn't always the right way and will just lead to different problems.
Bill Wied
Greenhorn

Joined: Mar 11, 2009
Posts: 9
My DD web.xml has the following header, but is not working. I believe it is correct for Tomcat 5.5.

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"; id="WebApp_ID" version="2.5">


Any ideas?

Bill
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
Sigh. Tomcat 5.5 doesn't support Servlet 2.5. That's exactly why I suggested Servlet 2.4. If you want to use Servlet 2.5, upgrade to Tomcat 6.0.

I repeat for the 2nd time: set web.xml to Servlet 2.4, nothing less or more.
Bill Wied
Greenhorn

Joined: Mar 11, 2009
Posts: 9
Thanks for the friendly response Bauke. ;)

I figured out the problem.
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
It is indeed not funny to see if others have a huge plate in front and repeatedly ignore your advice because they seem to know it better.
Bill Wied
Greenhorn

Joined: Mar 11, 2009
Posts: 9
Thanks again for your help.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: EL expressions not evaluating