This functionality is supported through the 
findAncestorWithClass(Tag, Class) 
static method of the Tag class which uses a reference to parent tag kept by each Tag instance, 
which effectively provides a run time execution stack.
5.7
Validation
Frequently there are constraints on how actions are to be used and when these constraints are 
not kept an error should be reported to the user.  There are several mechanisms in the JSP 1.1 
specification to describe syntactic and semantic constraints among actions; future 
specifications may add additional mechanisms.
5.7.1
Syntactic Information on the TLD
The Tag Library Descriptor contains some basic syntactic information.  In particular, the 
attributes are described including their name, whether they are optional or mandatory, and 
whether they accept request time expressions.  Additionally the 
bodycontent
 attribute can 
be used to indicate that an action must be empty.
All constraints described in the TLD must be enforced.  A tag library author can assume that 
the tag handler instance corresponds to an action that satisfies all constraints indicated in the 
TLD.
5.7.2
Syntactic Information in a TagExtraInfo Class
Additional translation time validation can be done using the 
isValid
 method in the 
TagExtraInfo
 class. The 
isValid
 method is invoked at translation time and is passed a 
TagData
 instance as its argument.
5.7.3
Raising an Error at Action Time
In some cases, additional request time validation will be done dynamically within the 
methods in the tag handler. If an error is discovered, an instance of 
JspError
 can be 
thrown. If uncaught, this object will invoke the errorpage mechanism of the JSP 
specification.
Chapter 5
Tag Extensions
110




JSP Web Hosting JavaServer Pages Specifications JSP Hosting




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