On 6/14/06, Calvin G. Dodge <[EMAIL PROTECTED]> wrote:
I'm maintaining and upgrading an existing Struts application (written by someone else long ago, with no chance of contacting the authors). I just discovered that our custom tag class variables have global scope - when a tag class (derived from javax.servlet.jsp.tagext.TagSupport) is used, an instance of that class is created - but then reused, rather than having a new instance created every time the tag is used in a JSP page. This puzzles and troubles me - it means that getters and setters are dealing with global values, rather than session values, and could lead to real trouble when we have enough users that 2 or more are using pages with the same tags at the same time. Is there some configuration issue I'm missing? I know that you can declare variable scope for form beans - is there a way to do this with custom tag classes?
The lifecycle of custom tag instances (Struts or JSTL or otherwise) is driven by the JSP Specification, and is version dependent. For JSP < 2.0, the container is allowed to reuse tag instances ... but it will have called release() on the old usage first. For JSP >= 2.0, tag instances are created for each use. Thanks!
Calvin Dodge Prosocial Applications, Inc.
Craig