180 likes | 271 Views
Chapter 7. Using Custom Tag Libraries and the JSP Standard Tag Library. What Is a Custom Tag Library?. Custom Actions Usage access to all information about the request add content to the response body as well as set response headers
E N D
Chapter 7 Using Custom Tag Libraries and the JSP Standard Tag Library
What Is a Custom Tag Library? • Custom Actions • Usage • access to all information about the request • add content to the response body as well as set response headers • use any Java API to access external resources such as databases, email servers, etc. • <prefix:tag atttribute=“value” />
Custom Tag Implementations • Java Classes
Custom Tag Implementations • Tag files (An example)
Custom Tag Library Tag Library Descriptor (TLD) JAR Custom Tag Implementations
Installing a Custom Tag Library • place the JAR file for the library in the WEB-INF/lib directory for the web application
Prefix use any prefix you like except jsp, jspx, java, javax, servlet, sun, or sunw Uri When the web application is started, the container scans through the WEB-INF directory structure for files with .tld extensions and all JAR files containing files with .tld extensions in their META-INF directory Declaring a Custom Tag Library
Declaring a Custom Tag Library • Relation between the taglib directive, the TLD, and the implementation (tag handler) for the custom actions
Identifying a Custom Tag Library in a JSP 1.1 Container • WEB-INF/web.xml • <%@ taglib uri="/WEB-INF/lib/orataglib_3_0.jar" prefix="ora" %>
Setting Action Attribute Values • Action attributes can be of any Java type • Automatic type conversion
The JSP Standard Tag Library • URI for the JSTL 1.1 libraries
Using Beans or Custom Actions • a bean is a great carrier of information • a custom action is great for processing information • Custom actions can use beans as input and output