Erik Beijnoff wrote:
Well, I have a finger or two in both specs ;-)


While I'm at it, and since you are working on the specs, you might be
interested in knowing another (sort of) odd behavior in Tomcat 5 when the
Jsp Document syntax is used.

When I use the <c:import> tag from JSTL I get this exception when I try to
pass in a EL expression as the "url" attribute:
"According to TLD or attribute directive in tag file, attribute url does not
accept any expressions"

This happens with most of the c:* JSTL tags. When the tag is changed to
c_rt:*, everything works fine.

Right, as strange as it may sound, this is the expected behavior, having to do with the fact that the EL was initially defined as part of the JSTL spec but will, starting with JSP 2.0, be part of the JSP spec.

In JSTL 1.0, the attributes that take EL expressions are declared as
_not_ accepting so-called "request-time attribute values" (rtexprvalue).
The reason is that in JSP 1.2 (which JSTL 1.0 is based on), an
rtexprvalue meant a Java expression (<%= ... %>). A JSP 1.2 container
have no idea what an EL expression is, so it passed it on to the tag
handler as a plain string value and the tag handler evaluated it.

In JSP 2.0 (when EL processing is enabled), the JSP container accepts
both Java and EL expressions as "request-time attribute values", and
evaluates them and pass the result to the tag handler. This means that
the attribute must be declared as accepting an rtexprvalue, and the
JSTL 1.0 "EL libraries" don't do that. The "RT libraries" do, however,
so that's why it works when you change from "c" to "c_rt".

A JSTL 1.1 version will be released at the same time as JSP 2.0, and
it will introduce new URIs for all libraries, identifying tag libraries
that declare the attributes as accepting rtexprvalue and letting the
JSP 2.0 container handle the evaluation.

So, you will basically have two options when deploying a JSTL-based
app in a JSP 2.0 container:
1) Keep the deployment descriptor at the Servlet 2.3 level (this
   disabled the container's EL procesing) and continue to use JSTL 1.0
   (meaning the tag handlers do the EL processing). In other words,
   deploy the application unchanged.
2) Migrate to JSTL 1.1 by switching to the Servlet 2.4 deployment
   descriptor (enabling the container's EL processing) and use the
   new JSTL URIs.

There's a middle-of-the-road approach as well: approach 2), but
selectively disable the container's EL processing for pages where you
want to continue to use JSTL 1.0 for some reason. I'm pretty sure
this alternative will turn out to have it's own set of issues, but
in theory, it's possible.

The url attribute id clearly stated to be able to be dynamic in the JSTL 1.0
spec. It seems as is if the container when it translates the Document into a
servlet, or some sort of intermediant jsp file turns the ${elExpression}
into a <%= elExpression %>, thereby invalidating the c:* tags.

See above.


Like I said,
it's not difficult to get around it, you can just change the c:* into a
c_rt:*, but I don't think that this is the behavior intended from the spec
writers, since from what I've learned, the use of c_rt:* should be
discouraged in favor of c:* tags.

Right, we encouraged using the "EL libraries". We thought we had a nice migration path to JSP 2.0 with the use of two separate library sets, but it turned out to be a bit more complicated that. What I do until there's a JSTL 1.1 implementation available is to just change the "uri" attribute in the "taglib" directives (e.g. from "c" to "c_rt") but keep the "prefix" attribute the same (e.g. "c"). This way I don't have to change prefixes all over the place, and I just have to change the "uri" prefix again when JSTL 1.1 is ready. In the XML case, you would do the same in the namespace declarations in <jsp:root>.

[...]
BTW, earlier discussed bug is now submitted.

Great.


Hans
--
Hans Bergsten                                <[EMAIL PROTECTED]>
Gefion Software                       <http://www.gefionsoftware.com/>
Author of O'Reilly's "JavaServer Pages", covering JSP 1.2 and JSTL 1.0
Details at                                    <http://TheJSPBook.com/>

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".

Some relevant archives, FAQs and Forums on JSPs can be found at:

http://java.sun.com/products/jsp
http://archives.java.sun.com/jsp-interest.html
http://forums.java.sun.com
http://www.jspinsider.com

Reply via email to