• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Tim Cooke
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Junilu Lacar
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Stephan van Hulst
  • Peter Rooke
  • Mikalai Zaikin
Bartenders:
  • Himai Minh

EL expressions not evaluating

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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. <c:out). 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><c:out value=
"${reqHead.key}"/></strong>: <c:out value="${reqHead.value}"/><br />

</c:forEach>


</body>
</html>

OUTPUT:

${reqHead.key}: ${reqHead.value}
 
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Sheriff
Posts: 67706
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Bill Wied
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 67706
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The most likely cause, as Bauke pointed out, is a misconfigured deployment descriptor.
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Sheriff
Posts: 67706
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 2458
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the friendly response Bauke. ;)

I figured out the problem.
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks again for your help.
 
You will always be treated with dignity. Now, strip naked, get on the probulator and hold this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic