[email protected]
[Top] [All Lists]

Re: <c:set> and runtime expressions

Subject: Re: <c:set> and runtime expressions
From: Kris Schneider
Date: Tue, 04 Apr 2006 08:51:01 -0400
Tarek Nabil wrote:
Thanks a lot Kris for the explanation.

Actually, I'm starting to feel that moving to JSTL 1.0 was not such a
wise move. There are a lot of things that I used to be able to do with
the Struts tag libraries that I can not do with JSTL. One of them is the
example I mentioned. Currently, the only work around for me is to do

Config config = Config.getIntance();

And then use config in later EL expressions. This is exactly what I
don't want to do, but unfortunately, it seems there's no other way
around it.

If that Config instance is likely to be required for most requests, perhaps you can use a Filter to set the instance as a request attribute. Or, if you're using Struts, have an Action do something similar before forwarding.

I'm starting to feel that JSTL has some severe limitations. Even with
1.1, I ran before into the problem of not being able to use constants.
Someone on this list kindly suggested the non standard tag library, but
the way it works (I guess) is that it uses reflection to expose those
static fields as properties, which is a very artificial solution. I
mean, why isn't this supported by default? I believe this is a question
for the JSR experts to answer.

Not sure why you'd characterize reflection that way, it's certainly a naturally occurring part of JavaBeans (not to mention Struts and BeanUtils). In fact, reflection was my approach to this very issue a few years back when using Struts:


Similar thread from this group:


Lots of other ways to approach the problem, but it is recognized as an issue:

"access to constants"

-----Original Message-----
From: Kris Schneider [mailto:[email protected]] Sent: Monday, April 03, 2006 5:57 PM
To: Tag Libraries Users List
Subject: Re: <c:set> and runtime expressions

Tarek Nabil wrote:

So that means if I use the RT-based version, then I won't be able to


EL? That's quite strange, because 1.1 could handle both, so it has to



In fact, that's exactly what it means. It's only as of JSP 2.0 that EL evaluation is done by the container. This means that both EL expressions

and JSP expressions can be used as RT attribute values. So, JSTL 1.1
isn't really handling anything, it's the JSP 2.0 container. Since JSP 1.2 doesn't do EL evaluation, it's up to a taglib (JSTL 1.0, for example) to do it. That's why the versions of the JSTL 1.0 taglibs that support EL evaluation have attributes with rtexprvalue = false.

-----Original Message-----
From: Kris Schneider [mailto:[email protected]] Sent: Monday, April 03, 2006 6:26 AM
To: Tag Libraries Users List
Subject: Re: <c:set> and runtime expressions

If you need to run JSTL 1.0 and want to use JSP expressions as


values, you need to use the "RT-based" versions. For JSTL, there are basically two distinct versions of each taglib:

<%@ taglib prefix="c"    uri="http://java.sun.com/jstl/core"; %>
<%@ taglib prefix="c_rt" uri="http://java.sun.com/jstl/core_rt"; %>

If you look at the TLD files for JSTL 1.0, you'll see:



JSTL 1.0 has to handle EL evaluation on its own (it's integrated into
JSP 2.0 so JSTL 1.1 doesn't need to do the evaluation), so you're forced

make a choice between different taglibs that use EL expressions or JSP


Tarek Nabil wrote:

Hi everyone,

I was using JSTL 1.1 in my application, and then unfortunately, I had


downgrade to 1.0. Now, my IDE is complaining about this line in my JSP

  <c:set var="config" value="<%= Config.getInstance() %>"/>

It says "Attribute value does not accept runtime expressions.

This used to work perfectly when I was using 1.1. I tried to look at


changes between 1.1 and 1.0 but I can not see anything related to this
issue. Is this really a difference between 1.0 and 1.1 or am I doing
something wrong?

Thanks in advance for your help.

Kris Schneider <mailto:[email protected]>
D.O.Tech       <http://www.dotech.com/>

To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

<Prev in Thread] Current Thread [Next in Thread>