« First entry! | Main | Microwave Safety »

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

TrackBack

TrackBack URL for this entry:
http://blogs.oracle.com/mt/mt-tb.cgi/7956

Comments (6)

Michael Laccetti:

I have to admit, this is more complicated then you make it out to be. A few of the fixes address getting it running in 10.1.3, but ignores backward compatibility. For example, while changing to the RT versions of the taglib will enable it to work under 10.1.3, the webapp won't work in 10.1.2 anymore. If you include the bit, the JSP won't even compile under 10.1.2. The jsp-config block means that the whole web-app won't even work under 10.1.2.

So yeah, great if we want to move to J2EE 1.4, but balls up the ass if we want to use JDev 10.1.3 to work on a J2EE 1.3 app.

Pretty frustrating. I wish I could stick with MyEclipse.

Didier Laurent:

Hi Michael,

most of the customers who contacted me so far wanted to migrate forward. This post was written with this in mind.
And those who wanted to continue working with JSTL 1.1 did in a J2EE 1.3 Web Project.

Regards,

Didier.

Megas:

Thanks a lot! This was very useful for my situation!

Didier Laurent:

Thanks - I'm happy it helped.

moo:

I am using JSTL 1.0 in a Servlet 2.3/JSP 1.2 web application. Using jdeveloper and embedded server, I've often got the Expression Language not supported in compile time attribute value error, but resolved it by a rebuild and server restart. (or once it was when the datesatmps on the jsp files seemed to have got in a mess).
However now i dont seem to be able to get past this problem. Do you have any advice ?

Thanks


Tuukka Mustonen:

Lots of time has passed but this post is still valid - helped me to resolve a similar issue. Thanks!

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 March 20, 2006 4:24 AM.

The previous post in this blog was First entry!.

The next post in this blog is Microwave Safety.

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

Powered by
Movable Type and Oracle