tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Pierre Delisle <pierre.deli...@sun.com>
Subject Re: Jasper tag class usage: bug?
Date Wed, 13 Dec 2000 16:39:26 GMT
Rickard,

The current implementation of Jasper (in all versions of tomcat) does
not 
"reuse" tag handlers. Not a bug, just a not-so-efficient implementation.
No-one has had/volunteered the time to look into it so far. We're just 
about done with the new JSP 1.2 features, and efficiency should become a 
priority in the near future.

Glenn has suggested some cool ideas that can help you in the short term.
And if you really care about efficiency and open source products, we'd
all be very happy to see you contribute ideas, patches, etc... to get
this
done asap.
 
    -- Pierre

Glenn Nielsen wrote:
> 
> Rickard Öberg wrote:
> >
> > Hi!
> >
> > I'm trying to optimize my tag library, especially for the case where
> > tags are used inside of iterating tags.
> >
> > Example:
> > <x:iterate>
> >   <x:dostuff foo="bar"/>
> > </x:iterate>
> > --
> > In the above case I want only one instance of the dostuff tag to be
> > created, since I am doing things with the foo attribute whose value
> > never changes (i.e. I compute things once in dostuff.setFoo() and want
> > to skip it for all other iterations).
> >
> > According to the JSP spec this should work great. However, when I look
> > in the generated JSP code (Tomcat 3.2 BTW), the dostuff tag is
> > instantiated for each iteration! This means that I cannot do the above
> > optimization. This adds a significant (and unnecessary) performance
> > penalty!
> >
> 
> According to to the spec, when a custom tag is closed out it falls out of
> scope and the object instantiated for its tag class can be recycled.
> 
> But you can design your tags to do what you want.
> There are two ways you could do this.
> 
> Split your x:dostuff tag into to tags like this:
> 
> <%-- The initstuff tag stores state information for the dostuff tag --%>
> <x:initstuff>
>  <x:iterate>
>   <%-- The dostuff tag uses findAncestorWithClass() to get the parent
>        xinitstuff object --%>
>   <x:dostuff/>
>  </x:iterate>
> </x:initstuff>
> 
> Another way is the following
> 
> <x:iterate>
>  <%-- the dostuff tag stores its state information as a PAGE_CONTEXT
>       attribute named "this" the first time through the loop.  On the remaining
>       iterations it gets the state information from the PAGE_CONTEXT
>       attribute named "this".  --%>
>  <x:dostuff id="this"/>
> </x:iterate>
> 
> ----------------------------------------------------------------------
> Glenn Nielsen             glenn@more.net | /* Spelin donut madder    |
> MOREnet System Programming               |  * if iz ina coment.      |
> Missouri Research and Education Network  |  */                       |
> ----------------------------------------------------------------------

Mime
View raw message