From what little I see, this is what you'll have to change:
1. A JSP 2.0 container uses JSTL 1.1.x You'll have to use the latest
JSTL 1.0.x taglib. Note that the URI for those two versions are
different. Make sure you use the correct one.
2. A JSP 1.2 container does not natively evaluate EL
The c:import tag is like the JSP include action, as opposed to the
JSP include directive. It's important to understand the difference
between these two. The latter includes at compile time, and the former
includes at run time. In other words, the include action executes the
specified resource
I believe you'll need to make your web.xml use the Servlet 2.4 schema.
-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: Friday, September 09, 2005 3:22 AM
To: taglibs-user@jakarta.apache.org
Subject: Problems using Taglibs 1.1: c:out
Hi,
i'm new to
Hold on there. I think you've misunderstood the intent of integrating
JSTL with Struts.
The idea is not to replace all Struts tags with JSTL tags. That's not
practical. In general, you should look at the functionality available
in the JSTL. If there's something that the JSTL does, and there's
To clarify some comments from other responders:
It is a good idea to use Struts-EL if you're going to use the JSTL.
However, for this particular example, the Struts tag library itself has
knowledge of c:forEach, as opposed to logic:iterate, so an html
Struts tag that uses indexed=true will work
It is trying to do the include at compile time, but your input is not
well-formed. You can't start an element in one file and end it in
another.
-Original Message-
From: Luca Passani [mailto:[EMAIL PROTECTED]
People, this one got me by surprise. I always thought that the statuc
It's a little hard to tell exactly what you're trying to do here, but it
might be helpful to know that '${restaurant.cuisine}' is the same as
'${restaurant[param.field]}' if param.field is equal to cuisine.
With this, you would need only the single case. This strategy is only
useful if you really
or
${restaurant[param.field]}
evaluated only once at the beginning of the table. param.field only
needs to be evaluated once as it becomes the name of the table.
Thanks,
Jack
Karr, David wrote:
It's a little hard to tell exactly what you're trying to do
here, but
it might
I would try this:
logic:iterate id=testScoreGraphResults name=printPreviewByTestBean
property=profLevelTOList indexId=testScoreGraphIndex
tr
td width=2%
bgcolor='c:out
value=${printPreviewByTestBean.profColorMapping[testScoreGraphResults.t
estScoreGraphIndex]}/'
-Original Message-
From: Wendy Smoak [mailto:[EMAIL PROTECTED]
From: anuradha.vaidya [EMAIL PROTECTED]
Now that there is no support for bean-el:write is there an
alternative
I
can
use for the same?
Is this a Struts question? If so, look at the README.txt
file in the
-Original Message-
From: luca [mailto:[EMAIL PROTECTED]
Karr, David wrote:
If your web container doesn't support JSP 2.0, and you want
to use the
EL in the attributes of your Struts tags, then you'll need
to utilize
the Struts-EL library, which you'll find
Well, first of all, there's no technical reason you can't use the JSTL
and Struts taglibs on the same page.
An important question is what web container you're using. If your web
container supports JSP 2.0, then you can use the EL in your JSP
(assuming you use the servlet 2.4 doctype, and a
Placing the TLD in the taglib jar works in JSP 1.2 also. That is not a
new feature.
In order to take advantage of it, you need the following:
* Keep the TLD in the taglib jar
* Do not put the taglib directive in the web.xml
* Specify a taglib directive in the JSP that uses the URI specified in
Note that this only works in a JSP 2.0 container, with the EL enabled.
If you're using Tomcat 4, or you haven't enabled the Servlet 2.4 version
of web.xml, or other hand-waving, then this won't work. However, this
is the best way to do it, if you can get it.
-Original Message-
From:
2.0 container, it just won't work. Just use Struts
by itself in a JSP 2.0 container and all the tags can use the EL (for
attributes that have rtexprvalue set to true).
-Original Message-
From: Pedro Salgado [mailto:[EMAIL PROTECTED]
On 20/9/04 10:11 pm, Karr, David [EMAIL PROTECTED
Other replies indicated your problem with the web.xml and JSP page.
Another point is that you don't use Struts-EL with JSP 2.0.
-Original Message-
From: Pedro Salgado [mailto:[EMAIL PROTECTED]
Sent: Monday, September 20, 2004 10:07 AM
To: [EMAIL PROTECTED]
Subject: standard-1.1.1
Those results seem reasonable. You should assume the value is a string,
unless you specifically have an integer type. In your case, the value
1 is a string. Now, if you did ${1}, that might give you an
integer.
-Original Message-
From: Starting out [mailto:[EMAIL PROTECTED]
i
If it isn't obvious yet, try:
c:redirect url=/SearchAction.do/
-Original Message-
From: Gao Di [mailto:[EMAIL PROTECTED]
i use struts framework in my project,and use the jstl
in the jsp page.now i want to write a page which will
auto forward to a struts action class,but
It might be interesting to see what it does with the following:
c:out value=${node.title}/
c:if test=${empty node}
is empty node
/c:if
c:if test=${empty node.title}
is empty node.title
/c:if
-Original Message-
From: Allistair Crossley [mailto:[EMAIL PROTECTED]
I would say there are several basic ideas here:
1. Use a JSP 2.0 container, like Tomcat 5. The JSTL is implemented
natively there.
2. Use solution 1.
3. Build a second tag library that's implemented exactly like Struts-EL.
Each tag class in Struts-EL is a subclass of the corresponding tag in
If you read the JSTL specification, you would have learned that the EL
doesn't reference scriptlet variables.
-Original Message-
From: Derek [mailto:[EMAIL PROTECTED]
This has got to be a really trivial thing, but this
doesn't work for me:
% String test = Happy Days; %
ptest:
How many items are in the collection? Four? Show us the class
represented by your employee object. That is probably the key.
-Original Message-
From: Rick Reumann [mailto:[EMAIL PROTECTED]
Sent: Saturday, April 03, 2004 10:42 PM
To: Tag Libraries Users List
Subject: JSP2.0 Tag
I'm not sure what is wrong. I used ExpressionEvaluatorManager (not
ExpressionUtil) to write Struts-EL, so you could inspect that code to
look for examples.
Ask about enabling aspects of Struts logging in struts-user. It uses
commons-logging, so you should be able to set up a logging.properties
You said that the bean labels is a java.util.List. However, you also
said table being the String The error message, stating 'Attempt
to convert String labels ...' appears to concur with the last
statement (that labels is a String, not a List). It sure seems like
labels is a String, not a
Read the specification. These questions are easily answered there. In
short, use the varStatus attribute.
-Original Message-
From: Adam Bickford [mailto:[EMAIL PROTECTED]
Sent: Thursday, February 12, 2004 12:36 PM
To: Tag Libraries Users List
Subject: Subtracting 2 values from
So the code above the redirect is only doing computation, and is not
intentionally generating output, correct? You might have to make your
code look ugly to prevent emitting newlines. As the number of items you
have to iterate through gets larger, the computation-only loop will be
generating
Whether it works or not, note that redirecting in JSP isn't really
considered a good idea. You run a risk of having your initial buffer
already being flushed to the client, which would throw an exception
(InvalidStateException?). It's best to make redirection decisions in
your application logic,
be aware of that, in any case.
-Original Message-
From: Colin Chalmers [mailto:[EMAIL PROTECTED]
Sent: Saturday, January 17, 2004 5:17 AM
To: Tag Libraries Users List
Subject: Re: Performance issues
Karr, David wrote:
Just in case, are you doing your measurements AFTER the first
Just in case, are you doing your measurements AFTER the first
generation/compile of the servlet? It's not meaningful to measure taglib
performance before then.
With respect to caching evaluation results, it's probably not worth
it, as it would have to do most of the evaluation before it could
I can't see how that could work. The c:import operation is processing
that URL in an external context. You'd probably have to use
jsp:include for that sort of thing.
-Original Message-
From: otisg [mailto:[EMAIL PROTECTED]
Here is the problem (using [] to avoid problems with email
Well, I can see several things here. First of all, it's important for
us to know what container and version you're using. From the error you
got from the JSTL test case, I'm guessing you're using one of the
revisions of Tomcat 5.
You talk about a bean that does some JDBC work. That certainly
As another poster pointed out, the source for the Struts-EL taglib is
one example of a library that specifically uses the EL. I would
recommend that you don't write a standalone library that uses the EL,
but instead extend a non-EL library, and keep all the real business
logic in the non-EL
-Original Message-
From: Morrow, Steve D. [mailto:[EMAIL PROTECTED]
I have a session-scoped bean structured (in part) as follows:
public class Customer {
public Integer id;
public String name;
public Integer getId() {
return id;
}
public String
You might get mileage out of something like this:
${requestScope[expression]}.
-Original Message-
From: [EMAIL PROTECTED]
i have, what is hopefully, a very brief question. does
anyone know of a way
to evaluate an EL statement that is cached in
request/session/etc scope?
say
Looks like you're missing a at the end of the c:if.
-Original Message-
From: Stephen Letschin [mailto:[EMAIL PROTECTED]
I am having a problem with a c:import that I hope someone has an answer
to.
lines deleted
%@ taglib uri=http://java.sun.com/jstl/core; prefix=c % %@ taglib
-Original Message-
From: Jacob Wilson [mailto:[EMAIL PROTECTED]
I am developing a new application in Struts and just wanted
to see how to implement JSTL in my jsps... I am trying to
iterate a loop using a jstl tag... I am specifying a
collection object in the items attribute of
-Original Message-
From: Lukas Bradley [mailto:[EMAIL PROTECTED]
What is the lifecycle of custom tags? Are tag objects reused
throughout a
page? It seems as if my tags are not always being created.
They are not
*always* reused however.
The custom tag lifecycle is probably
One way to get indirection is to use the fact that the several variable
scopes are all hashmaps available to the EL. So, if you have a variable
named formName that contains the name of a variable you want to
reference, you can reference pageScope[formName] to reference that
variable. If you use
-Original Message-
From: Eric W Hauser [mailto:[EMAIL PROTECTED]
On Wed, 3 Sep 2003, Felipe Leme wrote:
- you *have* to add the code that evaluates the expression.
With JSP 2.0 you
won't need to, it's done automatically
Although this is obviously a valid point, waiting
If you're using the non-RT version of the tag library, then you can't
use expression scriptlets for attribute values. You'll have to change
your initial c:set to this (untested):
c:set var=sectionListKey
%=Constants4Lists.SECTION_LIST %
/c:set
-Original Message-
From: Adam Hardy
You'll need to use a J2EE 1.3 compatible container to get this to work.
-Original Message-
From: e [mailto:[EMAIL PROTECTED]
Sent: Friday, August 22, 2003 11:10 AM
To: [EMAIL PROTECTED]
Subject: problems with install
I've downloaded the standard taglibs from
Do you have more than one getPo function? Do you have a setPo
function?
And a long shot, you might try changing po to something more than two
letters (making sure you change all your accessors in the same way).
-Original Message-
From: Shah, Shrihas (OFT) [mailto:[EMAIL PROTECTED]
The pre-JSP 2.0 version of the JSTL can reference properties of
JavaBeans, and entries of collections and maps. That's it.
If you have a bunch of constants that you might want to reference, you
might consider processing a class with reflection, loading all the
static final variables into a
-Original Message-
From: Rick Reumann [mailto:[EMAIL PROTECTED]
On Tue, 2003-07-22 at 10:54, Karr, David wrote:
If you have a bunch of constants that you might want to reference,
you
might consider processing a class with reflection, loading all the
static final variables
This has been discussed numerous times on this list.
The EL can reference javabean properties, and elements of collections
and maps. That's it. The length of a collection is not a javabean
property.
It's straightforward to implement a simple class called CollectionBean
(and MapBean) that is
As you may know by now, the EL in this version only allows you to access
javabean properties, and collection and map entries. You can't directly
get the length of a map or collection.
What I've done recently is implement a small class called
CollectionBean which has two javabean properties of
First of all, you will always run some risk if you try to redirect from
a JSP page. Nevertheless, if the redirect is near the top of the page
and your buffer size is of a reasonable size, you should be ok. If
you're failing, then you either have a miniscule buffer size, or your
redirect element
This is handled with the logic:present tag in Struts. You can't call
arbitrary methods in the first version of the JSTL.
-Original Message-
From: Jim Kennedy [mailto:[EMAIL PROTECTED]
Sent: Wednesday, June 25, 2003 12:58 PM
To: Tag Libraries Users List
Subject: JSTL and isUserInRole
Uh, no, that won't work. You can't call arbitrary methods in JSTL.
-Original Message-
From: Kumar, Kiran [mailto:[EMAIL PROTECTED]
change it to
c:if test=${pageContext.request.isUserInRole('foo')}
Thanks
KiranKumar (Raj)
ext 7203
-Original Message-
From: Jim
You'll find that complex applications will end up using more than one
tag library. It's not really practical to assume you'll do everything
with a single tag library, whether it's Struts, JSTL, or the Display tag
library. If you want to use both Struts and JSTL, you can use the
Struts-EL library
The attribute specification in your TLD needs to have rtexprvalue
set to true. Check the JSP specification or a JSP book about this.
-Original Message-
From: James Norman [mailto:[EMAIL PROTECTED]
Sent: Thursday, June 12, 2003 10:30 AM
To: [EMAIL PROTECTED]
Subject: Non EL enabled
I guess one thing that might help a tiny bit is if there was a map in
some scope that is formed by merging (in order) the applicationScope,
sessionScope, requestScope, and pageScope maps. That would give you a
single map to search, instead of having to know which scope to look in.
-Original
It's unfortunate, but that would be another strategy that would make
your life easier.
-Original Message-
From: Brian Buckley [mailto:[EMAIL PROTECTED]
David,
Thanks for your help.
Perhaps my convention of naming objects using their fully-qualified
package
names ought to be
Ask Struts questions on the struts-user list.
If you want to use the JSTL with Struts, you should probably use the
Struts-EL library, which is a contributed library in the nightly build.
-Original Message-
From: Giovanni Formenti [mailto:[EMAIL PROTECTED]
I have the JSTL/Struts
The Jakarta JSTL implementation provides a public API that you can use
in your own tag libraries. You can browse the javadoc for the
ExpressionEvaluatorManager class. You could also browse the source
code for the Struts-EL contributed library in the Struts distribution.
If you inspect the
The JSTL EL references JavaBeans properties, collections, and maps. That's it. If
you want to reference a constant, you'll have to have your business or setup logic put
the constant into a JavaBean property, collection, or map.
-Original Message-
From: René Zanner [mailto:[EMAIL
-Original Message-
From: Pierre Delisle [mailto:[EMAIL PROTECTED]
David M. Karr wrote:
This is probably obvious, but it is the case that any tag libraries
that
use
the ExpressionEvaluator class in the Jakarta JSTL implementation are
actually
dependent on the Jakarta
You likely will have more problems if you don't have time to read the
specification.
The JSTL expression language can only reference javabeans properties,
collections entries, and map entries. It can't reference variables
directly, and it can't call functions, except for javabeans property
Use the JSTL. It would be as simple as this:
c:out value=${SESSION_USER.firstName}/
Or if you wanted to make sure you got it from session scope:
c:out value=${sessionScope.SESSION_USER.firstName}/
-Original Message-
From: Sloan Seaman [mailto:[EMAIL PROTECTED]
Sent: Tuesday,
Well, if you want to validate this at translation time, then I guess a
TagExtraInfo class would do it. This will have a isValid() method,
which takes a TagData object, which is basically a hashmap of
attributes and values. You specify the presence of the TEI class in the
TLD.
-Original
It might be useful if we could see your JSP code, and any relevant bean code if it's
non-trivial.
-Original Message-
From: Schnitzer, Jeff [mailto:[EMAIL PROTECTED]]
Sent: Wed 02/12/2003 3:17 PM
To: [EMAIL PROTECTED]
Cc:
-Original Message-
From: Marc Guillemot [mailto:[EMAIL PROTECTED]]
Hi,
using Strugs I've a java.util.Locale object stored in session under
the
key
org.apache.struts.action.LOCALE. How can I output the language
property
of
this bean using c:out?
I've nothing outputted (what
-Original Message-
From: Donald Ball [mailto:[EMAIL PROTECTED]]
hi, i'm trying to figure out how to access static fields or methods
from a
static class using the jstl el. say i've got a class, call it
com.example.Foo, which has a method getBar(). how would i access that
property
Ideally, applications will be designed using the Web MVC paradigm, so
view pages will contain only view logic. However, in a complex
application, using even the most popular frameworks (Struts, for
instance), it's still difficult to completely avoid using scriptlets or
scriptlet expressions. If
How practical is it to consider deploying tools/frameworks using the EL
which do not use JSP? I looked in the two jar files (standard and
jstl), and it appears standard contains all the EL classes, but it
also contains some classes which are obviously JSP-related. If there's
no obvious
I'm familiar with the HTML tags for specifying images, either as a
static image or as a button. I'm also familiar with how tag libraries
work.
What are useful conventions for building custom tags in a tag library
that come with canned images? For instance, if a tag library provides
some sort of
In JSP 1.2, you have to specifically use the API for the JSTL expression language
engine if you want attributes to use the ${...} syntax. In JSP 2.0, this will
happen automagically, but we're not there yet.
If you want one example of how this is done, look at the Struts-EL contrib library,
?
I've looked through both the tags in the distribution and
CVS, but haven't
found an example.
Thanks!
-Original Message-
From: Karr, David [mailto:[EMAIL PROTECTED]]
In JSP 1.2, you have to specifically use the API for the JSTL
expression language engine if you want
-Original Message-
From: Mark R. Diggory [mailto:[EMAIL PROTECTED]]
I've been attempting this strategy, but it seems that in the web
application, somehow the properties files in the classes
directory don't
seem to get recognized by commons logging and used. When I compile my
The return value from doStartTag() can have three (more?) different
return values, being EVAL_BODY_INCLUDE, EVAL_BODY_BUFFERED, or
SKIP_BODY.
I don't see how the difference is silly. It was a good idea to
separate them, so tags which don't need to manipulate their body can be
more efficient.
Make sure you nest quotes correctly. That EL expression string you
supplied would be nested by single quotes.
-Original Message-
From: Hohlen, John [mailto:[EMAIL PROTECTED]]
Follow-Up Question:
If I want access a property from the bean, such as lastName,
what's the
syntax? I
A common pattern is to have your welcome file be a jsp that does nothing but forward
to your first action.
-Original Message-
From: Anuj Agrawal [mailto:[EMAIL PROTECTED]]
Is it accurate to say that we should never invoke a JSP file
directly? It
should always be forwarded to
If you're determined to put your business logic into your JSP pages, then just use a
scriptlet to create the list object and put it into the session. You can expect the
JSTL to well support applications which use the MVC pattern (by having view logic in
your JSP pages and business logic in
If these are constants in your application, you want to load this information ONCE,
into your application context. You would do this in a servlet's init() method, which
is set to load-on-startup, or you could add a ServletContextListener for the
application to do the same thing.
If Shawn's response wasn't clear, I'm not sure what else we can say. The EL parser
doesn't read scripting variables. It doesn't know anything about them. It can't use
them. Your first example doesn't work because it's trying to reference a scripting
variable. From the EL's point of view,
First of all, you're better off asking questions about Struts on the struts-user
list.
Your first issue:
You've mostly answered your own question. The automatic handling of form beans, both
in and out of pages, is a very powerful tool.
Your second issue:
There are several ways to handle
First of all, if you want to ask questions about Struts, ask them on the struts-user
list. You'll get better answers.
I don't know what you mean by user context, so I can't compare them.
Note that when using Struts, a good practice is to have all links go to Actions, not
directly to JSP
In (very) short, I believe it essentially checks the type in this order:
1. Collection
2. Bean
If it finds it is a Collection type, it won't introspect the object for
bean properties.
The workaround is to make your class not extend ArrayList, and include
the ArrayList as a bean property.
Even though you think you're using the JSTL RI, you're probably still
using the Resin implementation. Is anyone aware of a specific feature
that's different between the two implementations, so people can
determine with certainty which version they are using?
-Original Message-
From:
-Original Message-
From: Henri Yandell [mailto:bayard;generationjava.com]
Sent: Friday, November 01, 2002 11:21 AM
On Fri, 1 Nov 2002, Karr, David wrote:
If there's interest in EL-izing certain non-ELed tag libraries,
without changing the library (so the original library can
that very likely won't have any effect.
-Original Message-
From: Henri Yandell [mailto:bayard;generationjava.com]
Sent: Friday, November 01, 2002 12:31 PM
On Fri, 1 Nov 2002, Karr, David wrote:
All the tag classes in the Struts-EL tag library are
subclasses of the
corresponding
-Original Message-
From: Glenn Nielsen [mailto:glenn;mail.more.net]
Sent: Friday, November 01, 2002 1:02 PM
I would recommend creating the EL enabled version as a 2.0 release.
Enabling EL in an older non EL taglib can allow you to restructure
how your tags work. Some tags or tag
Wouldn't that just be ${!empty bean.myset.value}, or '${!empty
bean.myset[value]}'?
-Original Message-
From: Donald Ball [mailto:dball;rhoworld.com]
Sent: Wednesday, October 30, 2002 8:58 AM
To: [EMAIL PROTECTED]
Subject: simple question regarding EL and collections
I have a
It might be because you're missing the attribute name and =. You're just
inserting the value of ${bgColor} inside the tr tag, without it being a
value of an attribute.
-Original Message-
From: Stefan [mailto:nickm;studioweb.com]
Sent: Tuesday, October 29, 2002 12:55 PM
To: Tag
So you're telling us that referencing ${item.a_nomefile} in a c:out tag,
where item is an instance of DynaActionForm (or a subclass) actually
prints out the value of that property? I recently started looking into this
issue, and I frankly don't see how that can work. The properties of a
At end.
-Original Message-
From: Donald Ball [mailto:dball;rhoworld.com]
Sent: Thursday, October 24, 2002 9:12 AM
I'm getting the following exception:
- Root Cause -
javax.servlet.jsp.JspTagException:
javax.servlet.jsp.JspException: An error
occurred while evaluating
I believe that would be ${pageScope[user.name]}.
-Original Message-
From: Chen, Gin [mailto:Gin_Chen;tvratings.com]
Sent: Monday, October 21, 2002 7:06 AM
To: 'Tag Libraries Users List'
Subject: Special Chars in Param Name
Hi all,
How can I use jstl when accessing values
-Original Message-
From: Vernon Wu [mailto:vernonw;gatewaytech.com]
Sent: Monday, October 21, 2002 11:44 AM
I FIND THE PROBLEM! It is not mine, but the tag. See the below
The td fields are empty.
I use the script instead as I did in the controller. The data
is shown correctly.
-Original Message-
From: Vernon Wu [mailto:vernonw;gatewaytech.com]
Sent: Monday, October 21, 2002 11:44 AM
I FIND THE PROBLEM! It is not mine, but the tag. See the below
The td fields are empty.
I use the script instead as I did in the controller. The data
is shown correctly.
This seems confusing, but I think the specification is reasonably clear on
this. I believe you need ${pageContext.request.contextPath} instead.
-Original Message-
From: Chen, Gin [mailto:Gin_Chen;tvratings.com]
Sent: Friday, October 18, 2002 2:48 PM
To: 'Tag Libraries Users List'
Section A.3.4 of the specification talks about using the [] operator to
access maps. From this, you can see that your EL expression would be
${preferredNames[staffMember]}. If you're using Struts-EL, you can just
use that as your value value on your html-el:text element.
-Original
-Original Message-
From: Wendy Smoak [mailto:Wendy.Smoak;asu.edu]
Sent: Friday, October 18, 2002 4:56 PM
Section A.3.4 of the specification talks about using the
[] operator to
access maps. From this, you can see that your EL
expression would be
-Original Message-
From: Wendy Smoak [mailto:[EMAIL PROTECTED]]
Sent: Thursday, October 10, 2002 11:03 AM
To: 'Tag Libraries Users List'
Subject: Help with EL
I'm completely confused about whether or not I need JSTL with
Struts. All
I'm trying to do is iterate through a
-Original Message-
From: zze-JEANJEAN S ext FTRD/DMI/SOP
[mailto:[EMAIL PROTECTED]]
Sent: Thursday, October 03, 2002 7:46 AM
To: Tag Libraries Users List
Subject: RE: Euro character in c:out
I try to put :
%@ page contentType=text/html; charset=ISO-8859-1 %
But nothing
94 matches
Mail list logo