Re: JSP tags and tag recycling

From: John C. Bollinger (jobollin_at_indiana.edu)
Date: 03/14/05


Date: Mon, 14 Mar 2005 17:45:57 -0500

plm wrote:

> Hello,
>
> Thanks for your explanation.
> I'm not quite sure what you mean by this:
>
>
>>It depends on the details, but such recommendations are typically
>
> flat
>
>>wrong. In part _because_ of tag reuse, it is *forbidden* by JSP for
>
> any
>
>>tag handler state exposed as an attribute, whether optional or
>
> required,
>
>>to be modified by any means other than that attribute, as provided by
>
> a
>
>>page implementation using the handler. Furthermore, it is (or should
>
>
>
> What if a non mandatory attribute has default value "X", and has been
> set to "Y" on the first use of the tag instance? If I do not set the
> value of this attribute back to "X" for example in doEndTag, then what
> happens when the tag instance is being used once more? Are you telling
> that the JSP engine remembers the initial value of the attribute (i.e.
> the default) and then restores it before using the instance again?

When the tag instance is reused, the attribute still has the value "Y",
and THAT IS WHAT THE JSP CONTAINER EXPECTS. In a reuse scenario, the
container is *required* to *avoid* reinitializing any attribute with the
same target value that it already was initialized to. Those details are
moot, however, because JSP specifically says that tag handler properties
exposed as custom action attributes may not be modified other than by
their Javabeans setter methods, and that use of those methods is
reserved for the JSP container. (See JSP 2.0, page 2-51; substantially
the same requirements apply to earlier versions of JSP as well.)

Do note that the spec also says that tag handlers may only be reused
among custom action occurrences where the same set of attributes is
specified (though not necessarily with the same values). Perhaps that
will assuage some of your concern.

-- 
John Bollinger
jobollin@indiana.edu


Relevant Pages

  • Re: newbie: JSP vs Servlets
    ... The JSP container generates Servlet bytecode (sometimes directly, ... sometimes by generating java source and compiling it, ... build-time rather than on the first request to the server) from the jsp text. ...
    (comp.lang.java.programmer)
  • Re: Difficulties with Include Parameters/java.net.URLEncoder class
    ... > two include pages - a navigation page and a footer page. ... You cannot fix this in your JSP code: it is an issue with the JSP page ... You can seek a JSP container that does not have the issue, ...
    (comp.lang.java.programmer)
  • Re: .JSP file mapping?
    ... If the JSP container you use can unbderstand it, ... pick up the extra path elements via standard servlet APIs. ...
    (comp.lang.java.help)