tomcat-taglibs-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Agrawal, Anuj (Anuj)** CTR **" <>
Subject RE: c:set and scriptlets
Date Mon, 11 Mar 2002 16:25:14 GMT
I really didn't want to use scriptlets (per the documentation), but i was
running into situations where the JSTL actions were not (yet) supporting
some things that scriptlets could do.. OR SO I THOUGHT! 8((((

I've since then found a way around it using JSTL actions alone - so i'm a
little happier now.

I haven't found any detailed documentation on how i put different
programming expressions or what kind of statements i can and cannot place in
things like value="" or test="".. but throught trial and error and also this
wonderful mailing list, i'm learning about what's legal and what's illegal.

PS: Shawn - you rule! 8)

> Anuj was writing about the JSTL tag <c:set>, though.  JSTL 
> de-emphasizes
> scripting variables in favor of the expression language it introduces.
> Scripting variables are a reasonable mechanism for some 
> applications, but
> they inherently depend on scriptlets, which means that 
> they're useful only
> if a page author knows something about Java.  Scripting 
> variables can also
> be confusing many situations.  For instance, consider the 
> following code:
>    <%-- Sets a scoped attribute "four" with the value of 4 --%>
>    <c:set var="four" value="${2 + 2}"/>
>    <%-- Declares a scripting variable "four" to match this 
> scoped var --%>
>    <jsp:useBean id="four" type="java.lang.Number"/>
>    <%-- Replaces the scripting variablr "four" with the value 5 --%>
>    <% four = new Integer(5); %>
>    <%-- Prints out the value of the scoped variable "four" --%>
>    <c:out value="${four}"/>
> What do you expect the final <c:out> tag to output?  You 
> might think "5"
> because you replaced the scripting variable 'four' with an 
> Integer object
> for the number 5.  But the tag actually prints out "4", 
> because changing a
> scripting variable doesn't change the scoped variable that it was
> originally tied to.

To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message