Well, the JSP spec says it all - may want to take a look, or just write
a JSP page and have the compiler keep the generated code so you can look
at what it does.

JSP 7.1.2.1:
<quote>
The JSP page implementation class instantiates a tag handler object, or
reuses
an existing tag handler object, for each action in the JSP page. The
handler object
is a Java object that implements the javax.servlet.jsp.tagext.Tag
interface. The
handler object is responsible for the interaction between the JSP page
and
additional server-side objects.
</quote>

Thus, the JSP compiler will generally create a new instance to process
the tag in question. This is how nested tags may find their parents and
be able to lookup values within there. 

As for declared variables:

<quote>
JSP.2.11.1 Declarations
Declarations are used to declare variables and methods in the scripting
language
used in a JSP page. A declaration should be a complete declarative
statement, or
sequence thereof, according to the syntax of the scripting language
specified.
Declarations do not produce any output into the current out stream.
Declarations are initialized when the JSP page is initialized and are
made
available to other declarations, scriptlets, and expressions.

Examples
For example, the first declaration below declares an integer, global to
the
Scripting Elements 57
page. The second declaration does the same and initializes it to zero.
This type
of initialization should be done with care in the presence of multiple
requests
on the page. The third declaration declares a method global to the page.
<%! int i; %>
<%! int i = 0; %>
<%! public String f(int i) { if (i<3) return("..."); ... } %>
Syntax
<%! declaration(s) %>

</quote>

As for anything else generated for a JSP tag (including custom tags),
its declared within the body of the generated method by the JSP compiler
and thus they go on the stack for the thread, rather than the heap. 

James

> -----Original Message-----
> From: Kevin A. Smith [mailto:[EMAIL PROTECTED]] 
> Sent: Wednesday, August 28, 2002 12:54 PM
> To: Struts Users Mailing List
> Subject: RE: JSP thread safety
> 
> 
> Not sure about the taglib class variables (but I'd really 
> like the answer to that one also).
> 
> With respect to JSP thread safety, my understanding was that 
> any variables declared in the page were only in scope during 
> the execution of the page, much like variables in method 
> scope. If the pages in question are also declaring private 
> member variables or static variables, well that's another 
> story entirely.
> 
> --Kevin
> 
> -----Original Message-----
> From: Galbraith, Paul [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, August 28, 2002 1:34 PM
> To: [EMAIL PROTECTED]
> Subject: JSP thread safety
> 
> 
> Can someone clear up basics of JSP thread safety for me?  Can 
> I declare variables in scriptlets and maintain thread safety? 
>  Also, what about custom tags.  They declare class variables, 
> which makes me nervous...does the container ensure thread 
> safety for custom tags (assuming they release properly in the 
> release() method)?  Cheers,
>  
> Paul
> 
> --
> To unsubscribe, e-mail:   
> <mailto:struts-user-> [EMAIL PROTECTED]>
> For 
> additional commands, 
> e-mail: <mailto:[EMAIL PROTECTED]>
> 
> 

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to