Entering content frame

Process documentation Developing Custom JSP Tag Libraries Locate the document in its SAP Library structure

Purpose

The Java Server Pages™ 1.2 Specification defines a tag extension framework that enables developers to implement their own tags, and use them in their JSP pages. These tags are similar to the standard JSP action elements defined by the specification and, therefore, are often referred to as custom actions. A tag library represents a collection of custom JSP tags that are described in a specific descriptor (a text file in an XML format).

You need tag libraries if you want to modularize specific functions and make them available to your JSP pages. This way you can significantly reduce the Java code in your JSP pages, while still keeping them functional enough to fulfill the specific requirements of your business applications. Custom tag libraries also mean that code can be reused easily (implement them once and use them in multiple Web applications) and provide for easy application maintenance.

Elements of a Tag Library

A tag library consists of two types of elements as depicted on the following graphic:

This graphic is explained in the accompanying text

The tag library descriptor is an XML document that describes the custom JSP tags and specifies the mapping to the Java classes that implement the tags’ functions. The Document Type Definition (DTD) of that descriptor is defined by the Java Server Pages™ 1.2 Specification.

The tag handlers are the other type of components of a tag library. They are bean classes that implement the javax.servlet.jsp.tagext.Tag interface. They implement certain methods that define the functions of the tags, determine whether the tag accepts body, and so on.

Process Flow

The process of development of a tag library consists of the following two steps:

...

       1.      Implementing Tag Handlers

       2.      Describing the Tag Library

Result

Once you have developed the components of the tag library, you must package the compiled tag handler classes in a JAR file. You can then place them in the WEB-INF/lib directory of your Web application. The Tag Library Descriptor must be also placed in the WEB-INF directory.

Note

You can use the tag handler classes without packaging them in a JAR file. In this case, you must place them in the WEB-INF/classes directory of your web application (or another directory, but you must set classpath to it) so that they can be loaded.

 

 

 

Leaving content frame