tomcat-taglibs-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Shawn Bayern <>
Subject Re: Building my own agregates
Date Wed, 03 Jul 2002 12:44:43 GMT
JSTL isn't really meant for creating objects; it's meant for working with
them.  You can use <c:set> to store objects, move them between scopes,
etc., but we don't provide tags for creating HashMaps and so forth.  The
main reason for this is that it's beyond what most people seem to be doing
with JSP pages; in most applications, logic like this would fall to a
servlet, filter, listener, or other Java code.  (In fact, I proposed a
"Collections Taglib" at taglibs-dev, but there was, to be completely
honest, very little interest in the proposal.  I suspect that by and
large, people don't need such a facility -- or, at least, they haven't let
us know they do.)

As you suggest, you can attempt to stretch JSTL by using <jsp:useBean> to
create objects and <c:set target="..." property="..."> to create or edit
elements of Map objects.  But you'll end up with large collections of tags
in your JSP pages that have nothing to do with display, so even in small
applications, it might be easier to move the code elsewhere.

Shawn Bayern
"JSTL in Action"
(coming in July 2002 from Manning Publications)

On Wed, 3 Jul 2002, David Goodenough wrote:

> I am building a site using JSTL (1.0).  I need to be able to build up lists of
> objects, and components of those objects, during the life of a session.
> So I thought that should be easy, JSTL supports Vector and Map objects, all I
> need to be able to do it create them for myself rather than using the ones
> I get handed by things like the SQL tags.
> And I had vague memories of discussions (which I can not now find, I probably
> used the wrong keywords) of using jsp:useBean to do such things, but I can
> not find any reference to it in the taglibs spec, and so I thought I would
> ask here.
> What I need to be able to achieve, although I know this will not work, is:-
> <c:set var="list" value="new java.util.Vector( )" />
> and then later to be able to create an object such as a Hashtable and add
> it to the list, for which I would have expected to be able to do something
> like creating a new Hashtable, setting the values that I need within it, 
> and then adding it to the Vector list.  But I do not see how to invoke the
> relevant method on list.
> In the "old" days, in my first JSP work, I had mountains of embedded java, 
> but I am trying to follow the new paradym and not embed java and just use
> tags, but I can not see how to do this without embedded java.
> Is there an FAQ or guide to such things around somewhere?
> Thanks in advance
> David
> --
> To unsubscribe, e-mail:   <>
> For additional commands, e-mail: <>

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

View raw message