You are viewing a plain text version of this content. The canonical link for it is here.
Posted to taglibs-user@tomcat.apache.org by Mike Cantrell <Mi...@ind.alcatel.com> on 2002/10/22 19:30:57 UTC

release() methods for jakarta taglibs

We are encountering some problems with the Jakarta Taglibs with newer 
servlet containers that pool the tag objects (Tomcat  4.1.x and JRun 
4.0). Most of the tags I looked through don't override the release() 
method to reset the initial values and do cleanup.

For instance, the mailer taglib has a tag called mt:addrecipient. If you 
use this tag, each time the page is called the value is just appended to 
the original value. Are there any plans to go through these tags and 
make them "pool safe"?

Example:

    <mt:mail server="smtp">
        <mt:from><c:out value="${param.mail_from}" 
escapeXml="false"/></mt:from>
        <mt:subject><c:out value="${param.subject}" 
escapeXml="false"/></mt:subject>
        <c:forEach var="email" items="${emailList}">
            <mt:addrecipient type="to"><c:out value="${email}" 
escapeXml="false"/></mt:setrecipient>
        </c:forEach>
        <mt:message type="html">
            <div style="width: 500px;">
                <c:out value="${param.body}" escapeXml="false"/>
            </div>
        </mt:message>
        <mt:send/>
    </mt:mail>

Let's assume that emailList contains the addresess: jsmith@foo.com and 
johns@bar.com.

The first time the page is processed, the email sends out emails to:

     jsmith@foo.com, johns@bar.com.

If you hit reload, the email sends out to:

     jsmith@foo.com, johns@bar.com, jsmith@foo.com, johns@bar.com

and if you hit reload again, the email sends out to:
     jsmith@foo.com, johns@bar.com, jsmith@foo.com, 
johns@bar.com, jsmith@foo.com,
     johns@bar.com, jsmith@foo.com, johns@bar.com.


I've double checked the emailList  and it only contains the original 2 
elements each time the page reloads. It appears that the taglib is 
simply adding  the list to the old list from the Object obtained from 
the pool since there's no release() method to reset the tag's initial data.



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>