Developing a Simple Custom Tag

A custom tag is made up of two components:

  • A Java class file that implements the tag

  • An entry in a Tag Library Descriptor (TLD) file that defines the tag's name, its implementing Java class, and additional information necessary to deploy and use the tag

Using a custom tag requires a reference to the Tag Library Descriptor (TLD) at the start of the JSP. Multiple Tag Libraries can be used on the same Web page. After the TLD has been referenced, the custom tag from the TLD can be used like any other JSP tag.

Using a Simple Tag

To start learning to write and use TagLibs, you will implement a very simple custom tag that writes “Hello World” onto your Web page. This isn't a good use of a custom tag, but it will help you ...

Get Sams Teach Yourself J2EE™ in 21 Days now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.