Hello Bob,

comments inlined

> I have a nested row tag that shows data record(s) within a parent tag
> multiple times. I looked at the Jasper generated source and noticed that the
> object creation, setParent and setPageContext are invoked per row
> invocation. I.e. for the following:
>
> <my:loop times="4">
>
> <my:helloparam name="Bob">Stuff</my:helloparam><br>
>
> </my:loop>
>
> The nested tag is retrieved from pool and initialised four times. The spec
> is not clear on whether this is required behaviour, or whether Tomcat has
> missed a possible optimisation.

Possible, yes, but not guaranteed.  Remember that tag handler objects are
"fast moving" in the sense that they are being pulled from a pool and released
back to the pool very fast and very frequently.  And don't forget that other
requests for other pages might also use the same tag types.

The basic protocol (setPageContext, setParent, set attributes, doStartTag,
{doInitBody, doAfterBody}*, doEndTag) is defined in JSP.13.1 (JSP v2.0
PFD3, pg 2-50) but it takes a bit of reading between the lines.  This
protocol is also defined in state chart diagrams for tag lifecycles;
see pg 2-55 (for Tag), 2-59 (for IteratorTag), and 2-70 (for BodyTag).

> Ideally I would like the child within the parent to be initialised only
> once, so that I can obtain parameters from the parent only once and keep
> them. The advantage could be considerable if you have lots of initialisation
> per tag. I would like to know:
>
> 1) Is there a way (by tld declaration) to have the nested tag initialised
> only once within a parent?

No

> 2) Is what I want to do against the spec, or just against the way Tomcat
> works? The docs I have read do not say anything about /how many/ times the
> creation, setParent and setPageContext will happen.

The container is responsible for managing the lifecycle of *every* tag handler.
There are *some* possible optimizations, but this are *clearly* in the realm
of the container vendor and *not* in the spec; although the spec hints at the
possibilities (see middle of page 2-51).

Finally, remember that Tomcat is a "reference implementation" of the servlet/JSP
specs.  It is *not* an optimized, commercial Web container.  The goal of the
Tomcat team is to "get it right" first and foremost.  Having said this, I would
like to commend the Tomcat team for building a remarkably robust product.

-Bryan


+-----------------------------------+------------------------------------------+
| Bryan Basham                      | What we are today comes from our         |
| Java Courseware Developer         | thoughts of yesterday, and our present   |
| Sun Services                      | thoughts build our life of tomorrow:     |
|   Phone: 1-303-272-8766 (x78766)  |    our life is the creation of our mind. |
|  E-mail: [EMAIL PROTECTED]     | If a man speaks or acts with a pure      |
| Address: 500 Eldorado Blvd        | mind, joy follows him as his own shadow. |
|          MailStop: UBRM05-135     |  -- The Dhammapada (verse 2)             |
|          Broomfield, CO 80021     |     (trans. Juan Mascaro)                |
+-----------------------------------+------------------------------------------+

***************************************
SunNetwork 2003 Conference and Pavilion
"An unparalleled event in network computing! Make the net work for you!"

WHEN:  September 16-18, 2003
WHERE: Moscone Center, San Francisco

For more information or to register for the conference, please visit:
http://www.sun.com/sunnetwork

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".

Some relevant archives, FAQs and Forums on JSPs can be found at:

 http://java.sun.com/products/jsp
 http://archives.java.sun.com/jsp-interest.html
 http://forums.java.sun.com
 http://www.jspinsider.com

Reply via email to