5.5
Scripting Variables
The JSP specification supports scripting variables that can be declared within a scriptlet and 
can be used in another. The actions in a JSP page also can be used to define scripting 
variables so they can used in scripting elements, or in other actions; for example, the 
jsp:useBean standard action may define an object which can later be used through a scripting 
variable.
Since the logic that decides whether an action instance will define a scripting variable may 
be quite complex, this information is not encoded in the Tag Library Descriptor directly; 
rather, the name of a 
TagExtraInfo
 class is given in the TLD and the 
getVariableInfo
 method is used at translation time to obtain information on each 
variable that will be created at request time when this action is executed. The method is 
passed a 
TagData
 instance that contains the translation time attribute values.
The result of the invocation on 
getVariableInfo
 is an array of 
VariableInfo
objects.  Each such object describes a scripting variable by providing its name, its type, 
whether the variable is new or not, and what its scope is.  Scope is best described through a 
picture:.
NESTED
AT_BEGIN
  body
AT_END
The defined values for scope are:
NESTED
, if the scripting variable is available between the start tag and the end tag of the 
action that defines it.
AT_BEGIN
, if the scripting variable is available from the start tag of the action that 
defines it until the end of the page.
AT_END
, if the scripting variable is available after the end tag of the action that defines 
it until the end of the page.
The scope value for a variable implies what methods 
may
 affect its value and thus, in lack of 
additional information, where synchronization is needed:
Chapter 5
Tag Extensions
108




JSP Web Hosting JavaServer Pages Specifications JSP Hosting




 
TotalRoute.net Business web hosting division of Vision Web Hosting Inc. All rights reserved.