Hi Shawn,
This looks to me like it really is a bug in Tomcat, based on the
description of how AT_BEGIN and AT_END are supposed to work (for example,
on p. 200 of JSP 1.2 PFD2). The "status" variable exposed by the <x:a>
tag should really be visible where you have it accessed.
However, the question of "how early is too early" is an interesting
one. I've cc'd the JSR-053 expert group (responsible for the JSP
spec) for more feedback on that question.
Craig McClanahan
On Mon, 21 May 2001, Shawn Bayern wrote:
> This may not really be the best place to raise this question, but it's
> related to tag development and may affect the way tags should be designed.
>
> The JSP (1.2 PFD2) spec calls for AT_BEGIN and AT_END to provide for
> availability of scripting variables from the appropriate point "until the
> end of the page."
>
> I don't see any way of accomplishing that without also making the
> variables accessible earlier on the page as well. A scripting-variable
> declaration approximately adjacent to the calls to doStartTag() and
> doEndTag() -- which is where Jasper locates the declaration in the last
> version I checked -- might be contained within a Java '{ ... }' block as
> the result either of a scriptlet or of a block that the translator adds
> because of a stack of tags. Thus, the declaration would have only the
> narrow lexical "block" scope necessitated by the Java language, and it
> would not be available outside the containing block.
>
> To make it concrete... In the version of Jasper I tested with (with
> Tomcat 4.0 b3), if <x:a> produces an AT_BEGIN scripting variable called
> 'status', it will not be accessible when it's used in the following
> example:
>
> <x:b>
> <x:a/>
> </x:b>
> <%= status %>
>
> That may just be a bug in Jasper, or it may follow the intent of the spec.
> (I'm not sure -- I can't find anything in the spec that specifically
> supports or refutes this example, other than the language that describes
> AT_BEGIN as making a scripting variable available "until the end of the
> page." This makes me thing it's a bug.)
>
> If this is a bug, though, then the problem is that any fix would require
> the translator to declare a variable before any sub-block present on the
> page, and this would make scripting variables available too early. (The
> spec doesn't seem to rule that out -- i.e., maybe there's no such thing as
> "too early" -- but I could be wrong.)
>
> Does anyone know how other container handle similar situations? Any other
> thoughts? I might just be missing something obvious.
>
> Shawn
>
>