O'Reilly logo

Special Edition Using Java™ 2 Enterprise Edition by Mark Wutka

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 CheckerboardTag.java
 import javax.servlet.jsp.tagext.*; import javax.servlet.jsp.*; import java.io.*; public class CheckerboardTag extends TagSupport { // Variables to hold the attributes for the checkerboard protected int width = 40; protected int ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required