Prentice Hall and Sun Microsystems. Personal use only; do not redistribute.
326
Chapter 14 Creating Custom JSP Tag Libraries
Listing 14.10 HeadingTag.java (continued)
public int doStartTag() {
try {
JspWriter out = pageContext.getOut();
out.print(" " BGCOLOR=\"" + bgColor + "\"" +
" ALIGN=\"" + align + "\"");
if (width != null) {
out.print(" WIDTH=\"" + width + "\"");
}
out.print(">");
out.print("
"font size: " + fontSize + "px; " +
"font family: " + fontList + "; ");
if (color != null) {
out.println("color: " + color + ";");
}
out.print("\"> "); // End of
} catch(IOException ioe) {
System.out.println("Error in HeadingTag: " + ioe);
}
return(EVAL_BODY_INCLUDE); // Include tag body
}
public int doEndTag() {
try {
JspWriter out = pageContext.getOut();
out.print(" |
---|
");
} catch(IOException ioe) {
System.out.println("Error in HeadingTag: " + ioe);
}
return(EVAL_PAGE); // Continue with rest of JSP page
}
}
The Tag Library Descriptor File
There is only one new feature in the use of the
tag
element for tags that use
body content: the
bodycontent
element should contain the value
JSP
as
below.
JSP
The
name
,
tagclass
,
info
, and
attribute
elements are used in the same
manner as described previously. Listing 14.11 gives the code.
Second edition of this book: www.coreservlets.com; Sequel: www.moreservlets.com.
Servlet and JSP training courses by book's author: courses.coreservlets.com.
footer
Our partners:
PHP: Hypertext Preprocessor Best Web Hosting
Java Web Hosting
Jsp Web Hosting
Cheapest Web Hosting
Visionwebhosting.net Business web hosting division of Web
Design Plus. All rights reserved