JSP.5.5 Scripting VariablesThe 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 be 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 (Figure JSP.5-1). Figure JSP.5-1. Scope of Scripting Variables
The defined values for scope are:
The scope value for a variable implies what methods may affect its value and thus, in lack of additional information, where synchronization is needed:
|