Thread: JSTL
View Single Post
  #6 (permalink)  
Old August 8th, 2003, 04:57 PM
pdenhaan pdenhaan is offline
Authorized User
 
Join Date: Aug 2003
Location: Coventry, , United Kingdom.
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The price of working with a technology that isn't finalised yet, probably. What might also cause a problem is that a JSP container is supposed to switch to what one could term "JSP 1.2 compatibility mode" -- without expression language (EL) support -- when it finds a WEB-INF/web.xml file that conforms to the old Servlet 2.3 DTD rather than the 2.4 schema. It's undefined what happens if you don't have a web.xml file at all.

Many of my co-authors seem not to have realised this. Of course, it all worked fine in our prerelease software, making it easy to remain blissfully unaware of this. It will not work in production releases.

One thing to appreciate about the JSTL tags: if, in a JSP 1.2 container, you say

<%@taglib prefix="c" uri="http://java.sun.com/jstl/core"%>
<c:out value="${somevalue}"/>

you are passing the String "${somevalue}" into the JSP tag. This tag then calls an EL parser which figures out what you mean and evaluates the expression.

If, on the other hand, in a JSP 2.0 container you say

<%@taglib prefix="c" uri="http://java.sun.com/jstl/core_rt"%>
<c:out value="${somevalue}"/>

the container evaluates the ${somevalue} expression, which might return a primitive or any Object, and passes the result into the tag. That's why you need the _rt versions of the tags in a JSP 2.0 container. From a tag's perspective, the two code fragments above work completely differently even if they are the same to you.

The advantages? The main advantage is that EL is no longer restricted to the JSTL tags, as you do not need EL support in the tags themselves -- in a JSP 2.0 container, EL works for any tag, and can also be used in the HTML text itself.

 - Peter

Reply With Quote