O'Reilly logo

Struts Kick Start by Kevin Bedell, James Turner

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

JSP Custom Tags

As you develop your JSP application, you might find common functionalities that you repeatedly have to code in Java on the JSP page. For example, you might need to present metric values in English units, as in the previous example. JSP enables you to extend the JSP syntax by adding new custom tag libraries to JSP.

There are two pieces to a JSP tag library (taglib). The first is a Java class that actually handles the JSP. The second is a tag library descriptor file (TLD) that lets JSP know about the new tags.

To begin, you need to define a Java class that extends BodyTagSupport. This class provides all the helper functions and default methods needed to implement the BodyTag. Listing 5.13 shows an implementation of a meters-to-feet ...

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