tomcat-taglibs-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Hans Bergsten <>
Subject Re: Using scripting variables in a custom taglib
Date Tue, 14 Jan 2003 18:40:52 GMT
Patrick van Kann wrote:
> My apologies if this is not the right list for this question.

I've seen general tag library questions like this on the list before,
so it may be okay. But this list is really intended just for questions
about the libraries that are part of the Taglibs project. General
questions are probably better posted in Sun's JSP forum:


> I have written a JSP 1.2 compliant tag-libary that has nested and
> co-operating tags (it performs OQL queries using Castor as a back-end).
> At the moment, I do not make use of either <variable> elements in my
> descriptor, or JSP 1.1 "tag extra info" classes.
> I suspect that I should be using the <variable> tag, yet all works fine.
> My tags communicate happily using pageContext.setAttribute("myId", obj)
> and pageContext.getAttribute("myId"). Within my JSP pages, I can access
> variables defined in the tag using ${index}.

There's nothing wrong with that; in fact. I would say that it's now the
recommended way of exposing data from a custom tag. A TEI or <variable>
elements is needed only if you want to make it easy to read the data
from scripting code. But if it's rarely needed, I prefer skipping
variable declarations and tell users to use <jsp:useBean> to create
a scripting variable reference to the data instead.

> My question is where can I find a lucid demonstration of how to use the
> <variable> element correctly, or a detailed description/specification of
> how it should be used. Or even better, a book I could buy written by
> someone on this list!

Since you ask :-) My JSP book covers all of this; the recommendation
above plus how to declare variables when you really want to:


Hans Bergsten                                <>
Gefion Software                       <>
Author of O'Reilly's "JavaServer Pages", covering JSP 1.2 and JSTL 1.0
Details at                                    <>

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

View raw message