Accessing Tag Attributes

Just like regular tags, custom tags can have attribute values. You just need to provide get and set methods for each attribute. Although you enclose each attribute in quotes, you can have numeric attributes in your custom tag. The JSP engine performs the conversion automatically. Listing 16.24 shows a custom tag to display a checkerboard. The board has several options that can be changed by various attributes in the <xx:checkerboard> tag.

Code Listing 16.24. Source Code for
 import javax.servlet.jsp.tagext.*; import javax.servlet.jsp.*; import*; public class CheckerboardTag extends TagSupport { // Variables to hold the attributes for the checkerboard protected int width = 40; protected int ...

Get Special Edition Using Java™ 2 Enterprise Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.