jakarta-taglibs-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sudha...@thej2ee.com
Subject Re: Tag Interface and release() method.
Date Mon, 04 Oct 2004 20:35:52 GMT
I found it somewhere -

>From the JSP 2.0 specification: "The JSP container may reuse classic tag
handler instances for multiple occurrences of the corresponding custom
action, in the same page or in different pages, but only if the same set
of attributes are used for all occurrences."

Criterian for re-use was not known to me untill now.

Thanks Kris. You are 100% right :-)

JDBC connection was perhaps a bad example. But this can be a good example
when tag connection is pooled by other layer (vendor implementation of a
pooling DataSource). You really don't want each instance holding one

> IIRC, a tag handler instance can only be reused for another tag with the
> same
> set of attributes. I believe your example fails to meet that criterion.
> I'm
> also not sure that a JDBC connection is a good example of something to
> dispose
> of in the release method. It's probably a better idea to do something like
> have
> the tag handler implement TryCatchFinally and close the connection in the
> doFinally method.
> Quoting sudhaker@thej2ee.com:
>> Tag Interface and release() method.
> http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/jsp/tagext/Tag.html#release()
>> The API says - public void release() - Called on a Tag handler to
>> release
>> state. The page compiler guarantees that JSP page implementation objects
>> will invoke this method on all tag handlers, but there may be multiple
>> invocations on doStartTag and doEndTag in between.
>> It sounds to me that one can't rely on release() method for cleaning the
>> internal variable state. It should be only used for releasing other
>> resources (like JDBC connection).
>> <c:out value="${myvar1}" escapeXml="false" />
>> <c:out value="${myvar2}" />
>> According to API, the above code may have no xml escaping for myvar2 if
>> container reuses the Tag without calling release(). Also when I checked
>> code for JSTL (apache taglib project), I found their code relying on
>> release() method and expecting invocation of release() before the Tag is
>> returned to container pool. This means implementation JSTL by apache
>> taglib will behave unexpected if page compiler will not call release()
>> in
>> every cycle (which is totally valid according to API). Any optional
>> attributes may have non-default value based on their earlier invocation.
>> I also checked JSP compiled code (by WebLogic 8.1 JSP compiler) for
>> similar kind of code and found that they are invoking release() during
>> every cycle. So we are safe now, but some container can skip this and...
>> Any comments?
>> Regards,
>> Sudhaker
> --
> Kris Schneider <mailto:kris@dotech.com>
> D.O.Tech       <http://www.dotech.com/>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: taglibs-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: taglibs-dev-help@jakarta.apache.org

To unsubscribe, e-mail: taglibs-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-dev-help@jakarta.apache.org

View raw message