18.1. Tag LibrariesBefore jumping into the full standard tag library, it helps to consider how pages load and use simpler tags. Listing 18.1 uses a simple tag that displays the date and time in a configurable format, Listing 18.1. A JSP that uses a custom tag<%@ taglib prefix="awl" uri="http://toolbook.awl.com/samples"%> The time, in two different formats:<p> <awl:date format="EEEE, MMMM dd yyyy 'at' hh:mm"/><br> <awl:date format="hh:mm:ss MM/dd/yy"/><br> The tag library is loaded with the first line. The URI specifies the location of the tag library definition, and the prefix specifies the name that will be used to access the tags. Here the prefix is awl, but it could be anything as long as it is used consistently. One of the tags from this library, date, isused twice in the last two lines. The name of the tag is prepended by the prefix specified at the top.[1]
The awl:time tag itself simply sends the current time to the page in a format specified by the format property. In one sense this is not a particularly good example. Tags are intrinsically part of the view portion of an application, and so dealing with issues such as formatting a time for presentation is perfectly valid. However, the tag in |