JSP Tag Libraries

Скачать в pdf «JSP Tag Libraries»


■    Tags should make it possible to reference complex code via simple tag syntax.


■    Tags should allow us to perform tasks associated with web applications (such as reading parameters, cookies, redirecting, etc.) in a simple way.


■    Tags should be able to cooperate with one another and share information.


■    Tags should be able to read information from and write information to the JSP content in which they are embedded.


Perhaps the ultimate goal of custom tags is to have all the power and flexibility that free-standing Java code has in a JSP, but without the messiness of mixing Java and HTML. In order to accomplish these goals, the authors of the JSP specification needed to answer several questions:


■    How does the JSP environment know the identity of the tags and the handler classes implementing them?


■    How does the JSP environment know the attributes allowed for a specific tag?


■    How does a tag handler interact with a JSP page?


■    How does a JSP page interact with a tag handler?


■    How do tag handlers interact with each other?


Solutions to these and other questions were agreed upon and made available in version 1.1 of the JSP specification. There are four elements of the JSP specification in particular that address the use of custom tags. They are:


1    A special JSP custom tag API that all tags must obey (e.g., all tags must implement the Tag interface)


2    A strict life cycle and programming model for the tags

Скачать в pdf «JSP Tag Libraries»