You want to create a classic JSP 1.2-style tag handler for a custom action.
Create a Java class that extends
one of the
support classes in the
There are numerous types of custom tags you can create for JSPs, such as actions that ignore their bodies (empty tags), actions that are nested within other custom actions, and custom tags that use their body content. In fact, entire books have been dedicated solely to JSP custom tag development! Instead of being exhaustive in this book, I show how to create a fairly simple classic tag that adds an image logo to a JSP page with a text message. You can then infer details for your own programming tasks from this example.
The sample tag is designed to allow a page designer to specify an logo's image, its width and height, and a text message to sit alongside the image.
shows the classic tag
handler for this custom
action. This Java class
since it uses the tag's
nested content for the
logo's text message.
Example 22-1. A classic tag handler for inserting an image and markup
package com.jspservletcookbook; import javax.servlet.*; import javax.servlet.http.*;import javax.servlet.jsp.*; import javax.servlet.jsp.tagext.*; /** This tag generates a thumbnail image using the HTML img tag, next to a text message. The user specifies the content of the message and the Heading level (i.e., <H1>-<H6>) ...