When i use a taglib twice in the same page and the two instances of these tags share the same atrributes in the declaration but one of them have and attribute set using jsp:attribute, the value of this attribute is used in the other one too. Example <%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %> <html> <body> <h4>1 to 10 step 2</h4> <c:forEach var="i" begin="1" end="10"> <jsp:attribute name="step">2</jsp:attribute> <jsp:body> <c:out value="${i}"/> </jsp:body> </c:forEach> <br> <h4>1 to 10 no step</h4> <c:forEach var="i" begin="1" end="10" > <c:out value="${i}"/> </c:forEach> </body> </html> The output is Simple Range Iteration 1 to 10 step 2 1 3 5 7 9 1 to 10 no step 1 3 5 7 9 Expected Simple Range Iteration 1 to 10 step 2 1 3 5 7 9 1 to 10 no step 1 2 3 4 5 5 7 8 9 Thanks
Please see: http://tomcat.apache.org/faq/misc.html#tagbroken http://issues.apache.org/bugzilla/show_bug.cgi?id=16001
Well it has been a while since I reported this. I am not sure the current status of the implementation right now. At the time I checked the code, there was a bug in the way of picking the pooled instance, and since it was closed as invalid I will assume it was not fixed. From the JSP spec: "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. If a tag handler is used for more than one occurence, the container must reset all attributes where the values differ between the custom action occurrences. If an attribute value is set as a request-time attribute value (using a scripting or an EL expression), the container must reset the attribute between all reuses of the tag handler instance ..." The pool implementation is using attributes specified in the basic way for selecting a pooled instance. I mean: <mytag attr="1"/> But it is not considering the alternate way of specifying an attribute <mytag> <jsp:attribute name="attr">1</jsp:attribute> </mytag> From the spec: "The <jsp:attribute> action must only be used to specify an attribute value for standard or custom actions." So <jsp:attribute> is valid way of specifying an attribute for a custom action and TagLibs are actions, therefore, the container should use attributes defined by this mean when selecting the pooled instance. In the example code I posted originally (when I reported the bug), the same instance of the TagHandler is used, and although the attributes set differs, those attributes are not reset as the specification states. For the way the pool is implemented, a different instance should be used because an additional attribute is specified. As a conclusion, if a properly developed TagHandler is used and one of its attributes is specified using <jsp:attribute>, which is completely valid, the obtained result could be wrong due to the way the Pool is implemented.
Thanks for the report. I have fixed this in trunk and proposed the fix for 6.0.x and 5.5.x
This has been fixed in 6.0.x and will be included in 6.0.19 onwards
This has been fixed in 5.5.x and will be included in 5.5.28 onwards.