Chapter 14: Creating Custom JSP Tag Libraries
Source Code in This Chapter
Note:
right-click or shift-click on the links to download the associated file. All code is freely available for unrestricted use.
Order now
Simple Syntax Example
ExampleTag.java
JSP tag handler that just inserts a string ("Custom tag example...") into the output.
csajsp-taglib.tld
Tag library descriptor file for
ExampleTag
and others. Note that this file reflects changes from Tomcat 3.1 beta to Tomcat 3.1 final. See
csajsp-taglib-tomcat-3.1beta.tld
for the version that appeared in the book.
SimpleExample.jsp
A page that uses the tag handled by
ExampleTag
.
Basic Tag
SimplePrimeTag.java
Tag handler that outputs a random 50-digit prime. Uses the
Primes
class.
csajsp-taglib.tld
Tag library descriptor file for
SimplePrimeTag
and others.
SimplePrimeExample.jsp
A page that uses the tag handled by
SimplePrimeTag
.
Assigning Attributes to Tags
PrimeTag.java
Tag handler that outputs an N-digit prime number. Extends
SimplePrimeTag
.
csajsp-taglib.tld
Tag library descriptor file for
PrimeTag
and others.
PrimeExample.jsp
A page that uses the tag handled by
PrimeTag
.
Including the Tag Body
HeadingTag.java
Tag handler that ouputs a fancy HTML "heading" implemented as a table with embedded style sheet information.
csajsp-taglib.tld
Tag library descriptor file for
HeadingTag
and others.
HeadingExample.jsp
A page that uses the tag handled by
HeadingTag
.
Optionally Including the Tag Body
DebugTag.java
Tag handler that includes or omits debugging information depending upon the value of a request time parameter.
csajsp-taglib.tld
Tag library descriptor file for
DebugTag
and others.
DebugExample.jsp
A page that uses the tag handled by
DebugTag
.
Manipulating the Tag Body
FilterTag.java
Tag handler that replaces the HTML-specific characters such as < and > with their character entities (<, >, etc.). Uses the static
filter
method of the the
ServletUtilities
class.
csajsp-taglib.tld
Tag library descriptor file for
FilterTag
and others.
FilterExample.jsp
A page that uses the tag handled by
FilterTag
.
Including or Manipulating the Tag Body Multiple Times
RepeatTag.java
Tag handler that repeats the tag body the number of times that the
reps
attribute specifies.
csajsp-taglib.tld
Tag library descriptor file for
RepeatTag
and others.
RepeatExample.jsp
A page that uses the tag handled by
RepeatTag
.
Using Nested Tags
Template for nested tags
IfTag.java
Tag handler for main part of "if" tag (enclosing tag).
IfConditionTag.java
Tag handler for condition part of "if" tag (first nested tag).
IfThenTag.java
Tag handler for "then" action part of "if" tag (second nested tag).
IfElseTag.java
Tag handler for "else" part of "if" tag (third nested tag).
csajsp-taglib.tld
Tag library descriptor file for
IfTag.java
,
IfConditionTag.java
,
IfThenTag.java
,
IfElseTag.java
and others.
IfExample.jsp
A page that uses the tag handled by
IfTag
etc.
JSP-Styles.css
Style sheet used by JSP documents in this chapter.
General
On-site servlet and JSP short courses.
Taught at
your
location.
Public (open enrollment) servlet and JSP short courses.
For those without enough people to justify an on-site course.
Order from amazon.com.
Free examination copies for instructors.
For courses that are considering the use of the book.
Course materials
License materials for use in your own courses.
Reader reviews.
Table of contents.
Also available
in PDF
.
Index.
Adobe acrobat (PDF) format.
API for all code.
Javadoc format.