- java.lang.Object
-
- javax.servlet.jsp.tagext.VariableInfo
-
public class VariableInfo extends 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 have an associated scope of either AT_BEGIN, NESTED, or AT_END.
The class name (VariableInfo.getClassName) in the returned objects is used to determine the types of the scripting variables. Note that because scripting variables are assigned their values from scoped attributes which cannot be of primitive types, "boxed" types such as
java.lang.Integer
must be used instead of primitives.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.4 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. The class must also be in the CLASSPATH for the Web Application (see Servlet 2.4 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 Java EE). 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 2.0 specification defines the interpretation of 3 values:
- 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 scope.
- AT_END, if the scripting variable is available after the end tag of the action that defines it until the end of the scope.
Variable Synchronization Points
doStartTag() doInitBody() doAfterBody() doEndTag() doTag() Tag
AT_BEGIN, NESTED
AT_BEGIN, AT_END
IterationTag
AT_BEGIN, NESTED
AT_BEGIN, NESTED
AT_BEGIN, AT_END
BodyTag
AT_BEGIN, NESTED1
AT_BEGIN, NESTED1
AT_BEGIN, NESTED
AT_BEGIN, AT_END
SimpleTag
AT_BEGIN, AT_END
doStartTag()
ifEVAL_BODY_INCLUDE
is returned, or afterdoInitBody()
otherwise.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
Fields Modifier and Type Field and Description 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
Constructors Constructor and Description VariableInfo(String varName, String className, boolean declare, int scope)
Constructor These objects can be created (at translation time) by the TagExtraInfo instances.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description String
getClassName()
Returns the type of this variable.boolean
getDeclare()
Returns whether this is a new variable.int
getScope()
Returns the lexical scope of the variable.String
getVarName()
Returns the name of the scripting variable.
-
-
-
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(String varName, String className, boolean declare, int scope)
Constructor These objects can be created (at translation time) by the TagExtraInfo instances.- Parameters:
varName
- The name of the scripting variableclassName
- The type of this variabledeclare
- 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 String getVarName()
Returns the name of the scripting variable.- Returns:
- the name of the scripting variable
-
getClassName
public String getClassName()
Returns the type of this variable.- Returns:
- the type of this variable
-
getDeclare
public boolean getDeclare()
Returns whether this is a new variable. If so, in some languages this will require a declaration.- Returns:
- whether this is a new variable.
-
-
Nederlandse vertaling
U hebt gevraagd om deze site in het Nederlands te bezoeken. Voor nu wordt alleen de interface vertaald, maar nog niet alle inhoud.Als je me wilt helpen met vertalingen, is je bijdrage welkom. Het enige dat u hoeft te doen, is u op de site registreren en mij een bericht sturen waarin u wordt gevraagd om u toe te voegen aan de groep vertalers, zodat u de gewenste pagina's kunt vertalen. Een link onderaan elke vertaalde pagina geeft aan dat u de vertaler bent en heeft een link naar uw profiel.
Bij voorbaat dank.
Document heeft de 11/06/2005 gemaakt, de laatste keer de 18/08/2025 gewijzigd
Bron van het afgedrukte document:https://www.gaudry.be/nl/java-api-javaee-rf-javax/servlet/jsp/tagext/VariableInfo.html
De infobrol is een persoonlijke site waarvan de inhoud uitsluitend mijn verantwoordelijkheid is. De tekst is beschikbaar onder CreativeCommons-licentie (BY-NC-SA). Meer info op de gebruiksvoorwaarden en de auteur.
Referenties
Deze verwijzingen en links verwijzen naar documenten die geraadpleegd zijn tijdens het schrijven van deze pagina, of die aanvullende informatie kunnen geven, maar de auteurs van deze bronnen kunnen niet verantwoordelijk worden gehouden voor de inhoud van deze pagina.
De auteur van deze site is als enige verantwoordelijk voor de manier waarop de verschillende concepten, en de vrijheden die met de referentiewerken worden genomen, hier worden gepresenteerd. Vergeet niet dat u meerdere broninformatie moet doorgeven om het risico op fouten te verkleinen.