Web Development with JavaServer Pages

Скачать в pdf «Web Development with JavaServer Pages»


public ValidationMethod[] validate (String uri, String prefix,


javax.servlet.jsp.tagext.PageData page)


As its signature indicates, the JSP container passes three arguments to the vali-date() method when it is called to validate a JSP page. The first two arguments are character strings identifying the URI of the tag library’s TLD and the prefix used by the library’s custom tags within the page, respectively. The values of these two arguments thus correspond directly to the values of the taglib directive or xmlns attributes that caused the validator to be called in the first place.


The final parameter of the validate () method is an instance of the javax.serv-let.jsp.tagext.PageData class. It is this instance that exposes the contents of the JSP page to the validator. This class supports just a single method, getInput-Stream(), that returns an instance of j ava.io. InputStream for reading the XML representation of the page. The validate () method can then pass this input stream to an XML parser for extracting and validating the relevant custom tags.


Based on these three inputs, then, the validate() method knows how the tag library is being referenced by the page, and has full access to the contents of the page. Using this information, it is able to determine whether or not the use of the tag library by the page is valid. It is the ValidationMessage array returned by this method that conveys this determination to the JSP container. If the validator finds no problems with the contents of the JSP page, it is expected to return either null

Скачать в pdf «Web Development with JavaServer Pages»