[ Team LiB ] |
![]() ![]() |
Tag Files—Tag Extensions Without JavaTag files make it possible for Web developers to create tag handlers without knowing Java. Tag files are created using JSP syntax and produce a tag handler at translation time. Let's jump right in and create our first tag file, as shown in Listing 16.21. Listing 16.21 Source Code for HelloWorld.tagHello World Remarkably, that's all there is to it. The tag must have an extension of .tag. The source for a JSP that uses HelloWorld.tag is found in Listing 16.22. Listing 16.22 Source Code for HelloWorld.jsp<%@ taglib prefix="tags" tagdir="/WEB-INF/tags" %> <tags:HelloWorld /> To deploy a tag file, you can place it in one of two locations:
If you elect to deploy your tag file (as part of an application or library) in a JAR file, you must create a TLD for it. A new element, <tag-file>, describes tags within a tag library. It consists of two subelements, name and path, which define the name of the tag and location of the tag file. <tag-file> is analogous to <tag>, and both can be used within the same tag library. |
[ Team LiB ] |
![]() ![]() |