O'Reilly logo

JavaServer Pages™, Second Edition by Larne Pekowsky

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

Chapter 13. Creating New Tag Libraries

Since Chapter 4, we have seen that custom tag libraries are an invaluable asset. The time has now come to learn how to create new ones. Fundamentally, tags are not much more complicated than servlets; in fact, servlets could be used to construct a very limited form of custom tag. If it rendered the current time to a page, a servlet could be used almost as a “tag”:

<jsp:include page="/dateServlet">
  <jsp:param name="format" value="HH:MM:SS"/>
</jsp:include>

Alternatively, if tags were implemented as servlets and held to the bean naming conventions, the page compiler could take a simple JSP:

Here is the date:
<awl:date format="HH:MM:SS"/>
<p>

and turn it into the following code:

 public void service(HttpServletRequest ...

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