« How to add JDK 1.5 API Reference to JDeveloper 10.1.3 | Main | The (AJA)X Files by Lucas Jellema »

JSTL 1.0 in JSP 2.0 Pages

The problem

We had several customers who reported the same issue last week through MetaLink. I see that others also created a Forum thread:

JSP pages with JSTL including EL gives the following error at compilation in JDeveloper 10.1.3:

Error(<line number="">): Expression Language not supported in compile time attribute value
</line>

or the following when running the page in OC4J:
500 Internal Server Error
OracleJSP: oracle.jsp.parse.JspParseException: /Name.jsp: Line # 13, <c:out value="Hello, my name is ${LastName}, ${FirstName} ${LastName}">
Error: Expression Language not supported in compile time attribute value</c:out>
The same pages could compile and run without any problem with JDeveloper 10.1.2.

The cause

This happens when using JSTL 1.0 in JSP 2.0
When the Deployment Descriptor (web.xml) is from version 2.4 - you see it in your web.xml file:
<web-app (...) version="2.4" (...) >
then the default mode for JSP pages is to evaluate EL expressions, what raises the above errors when JSTL 1.0 libraries are used.

The solution(s)

Depending on the fact you want to continue working with the JSTL 1.0 libraries or not, here are different solutions you can implement:
  1. use the JSTL 1.1 libraries;
    you should add the 1.1 libraries to your Project and replace the URIs in your pages, as they are different between the 2 versions.
    The new URIs are similar to the old JSTL 1.0 EL URIs, except that jsp/ has been added in front of jstl, stressing JSTL's dependency on the JSP specification (which now "owns" the EL).
    For example:
    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
  2. use the "Request-Time" (..._rt) JSTL 1.0 libraries:
    for example, if you use the core library, replace "core" by "core_rt"
    <%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
  3. Create your JSP Pages in a Project with a 2.3 Deployment Descriptor
     
    Each JSP page has a default mode for EL expression evaluation. The default value varies depending on the version of the web application deployment descriptor.
    The default mode for JSP pages delivered with a Servlet 2.4 descriptor is to evaluate EL expressions.
    The default mode for JSP pages delivered using a Servlet 2.3 or earlier descriptor is to ignore EL expressions.
    So, if you create your JSP pages with JSTL 1.0 in a "Servlet 2.3/JSP 1.2 (J2EE 1.3)" Web Project (when you create a "Web Project" in JDeveloper 10.1.3, you are prompted for its version), the EL will be ignored and your page will compile.

  4. Deactivate the EL evaluation with a Page directive or in the Deployment Descriptor:
    You can deactivate the EL evaluation either at the JSP page level, in the page directive, by setting the isELIgnored attribute to "true":
    <%@ page (...)  isELIgnored="true" %>
    or in your Deployment Descriptor (web.xml), by setting the <el-ignored></el-ignored> element to true (subelement of <jsp-property-group></jsp-property-group>):
    (...)
        <jsp-config>
            <jsp-property-group>
                <display-name>Ignore EL</display-name>
                <url-pattern>*.jsp</url-pattern>
                <el-ignored>true</el-ignored>
            </jsp-property-group>
        </jsp-config>
    (...)

In case you have access to MetaLink (*), I also created Note 361806.1 - JSTL Including EL Raises Error "Expression Language not supported in compile time attribute value"

(*) MetaLink requires a login that you get with your Oracle Support licence.

References

Post a comment

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)

About This Entry

This page contains a single entry from the blog posted on May 25, 2006 12:00 AM.

The previous post in this blog was How to add JDK 1.5 API Reference to JDeveloper 10.1.3.

The next post in this blog is The (AJA)X Files by Lucas Jellema.

Many more can be found on the main index page or by looking through the archives.

Top Tags

Powered by
Movable Type and Oracle