javax.servlet.jsp.tagext
Class VariableInfo

java.lang.Object
  |
  +--javax.servlet.jsp.tagext.VariableInfo

public class VariableInfo
extends java.lang.Object

Information on the scripting variables that are created/modified by a tag (at run-time). This information is provided by TagExtraInfo classes and it is used by the translation phase of JSP.

Scripting variables generated by a custom action may have scope values of page, request, session, and application.

The class name (VariableInfo.getClassName) in the returned objects are used to determine the types of the scripting variables. Because of this, a custom action cannot create a scripting variable of a primitive type. The workaround is to use "boxed" types.

The class name may be a Fully Qualified Class Name, or a short class name.

If a Fully Qualified Class Name is provided, it should refer to a class that should be in the CLASSPATH for the Web Application (see Servlet 2.3 specification - essentially it is WEB-INF/lib and WEB-INF/classes). Failure to be so will lead to a translation-time error.

If a short class name is given in the VariableInfo objects, then the class name must be that of a public class in the context of the import directives of the page where the custom action appears (will check if there is a JLS verbiage to refer to). The class must also be in the CLASSPATH for the Web Application (see Servlet 2.3 specification - essentially it is WEB-INF/lib and WEB-INF/classes). Failure to be so will lead to a translation-time error.

Usage Comments

Frequently a fully qualified class name will refer to a class that is known to the tag library and thus, delivered in the same JAR file as the tag handlers. In most other remaining cases it will refer to a class that is in the platform on which the JSP processor is built (like J2EE). Using fully qualified class names in this manner makes the usage relatively resistant to configuration errors.

A short name is usually generated by the tag library based on some attributes passed through from the custom action user (the author), and it is thus less robust: for instance a missing import directive in the referring JSP page will lead to an invalid short name class and a translation error.

Synchronization Protocol

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:

The JSP 1.2 specification defines the interpretation of 3 values:

The scope value for a variable implies what methods may affect its value and thus where synchronization is needed:

Variable Information in the TLD

Scripting variable information can also be encoded directly for most cases into the Tag Library Descriptor using the <variable> subelement of the <tag> element. See the JSP specification.


Field Summary
static int AT_BEGIN
          Scope information that scripting variable is visible after start tag
static int AT_END
          Scope information that scripting variable is visible after end tag
static int NESTED
          Scope information that scripting variable is visible only within the start/end tags
 
Constructor Summary
VariableInfo(java.lang.String varName, java.lang.String className, boolean declare, int scope)
          Constructor These objects can be created (at translation time) by the TagExtraInfo instances.
 
Method Summary
 java.lang.String getClassName()
           
 boolean getDeclare()
           
 int getScope()
           
 java.lang.String getVarName()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NESTED

public static final int NESTED
Scope information that scripting variable is visible only within the start/end tags

See Also:
Constant Field Values

AT_BEGIN

public static final int AT_BEGIN
Scope information that scripting variable is visible after start tag

See Also:
Constant Field Values

AT_END

public static final int AT_END
Scope information that scripting variable is visible after end tag

See Also:
Constant Field Values
Constructor Detail

VariableInfo

public VariableInfo(java.lang.String varName,
                    java.lang.String className,
                    boolean declare,
                    int scope)
Constructor These objects can be created (at translation time) by the TagExtraInfo instances.

Parameters:
className - The name of the scripting variable
declare - If true, it is a new variable (in some languages this will require a declaration)
scope - Indication on the lexical scope of the variable
Method Detail

getVarName

public java.lang.String getVarName()

getClassName

public java.lang.String getClassName()

getDeclare

public boolean getDeclare()

getScope

public int getScope()


Copyright ? 2000 Mortbay Consulting Pty. Ltd. All Rights Reserved.