Custom tags

Custom tags, also called tag extensions or custom actions, extend the capabilities of JSP pages. Tag libraries define a set of actions to be used within a JSP page for a specific purpose, such as handling SQL requests. The tag libraries you use in PowerBuilder can be built using another tool, although you can create custom tags for Web services using a PowerBuilder wizard (see “JSP Web services”).

The URI identifying a tag library is associated with a Tag Library Descriptor (TLD) file and with tag handler classes.

Tag handlers

A tag handler is a Java class that defines the semantics of an action. The implementation class for the JSP instantiates a tag handler object for each action in the page. Tag handler objects implement the javax.servlet.jsp.tagext.Tag interface, which defines basic methods required by all tag handlers, including doStartTag and doEndTag. The BodyTag interface extends the Tag interface by adding methods that enable the handler to manipulate its body.

Packaging tag libraries

To associate a tag library with a JSP page, you use a taglib directive that identifies the URI where the tag library’s TLD file can be located. The TLD file must be in (or deployed to) the class path of the JSP container and is usually placed in the Web application’s WEB-INF /tlds directory. The class files for the tag library must also be in the class path of the JSP container. Typically they are placed in the Web application’s WEB-INF/classes directory or in a JAR file in the WEB-INF/lib directory.

For information on adding a taglib directive to a JSP page, see “Taglib directive”.

Using tag libraries in PowerBuilder JSP pages

In PowerBuilder, you can add tag libraries to a JSP page from the Components tab of the System Tree as well as from the JSP Directives page of the Page Properties dialog box. A tag library must be in the PowerBuilder custom tag library search path in order to be listed on the Components tab. You can add directories or tag library descriptor files to the custom tag library search path on the JSP page of the System Options dialog box.

When you add a tag library to a JSP page, a dialog box prompts you to enter a prefix. The prefix you enter is used as a shorthand entry to refer to the tag library when you add a tag from the library to the page. PowerBuilder automatically includes the path to the TLD file in the web.xml file for the target to which the page belongs. PowerBuilder also adds an entry for the tag library on the Tag Libraries page of the Deployment Configuration Properties dialog box for the target.

For more information about the Tag Libraries page of the Deployment Configuration Properties dialog box, see “Tag Libraries”.