Introduction to JSP custom tags:
Custom tags are application programmers’ defined actions which represent presentation logic as reusable components. The facility of defining custom tags makes the JSP extensible. To understand the use of custom tags, lets consider the following scenario. Let there be a web application in which 10 pages displays user data in tabular format. These pages can be defined in two ways:
1. In each page HTML <table>,<tr>,<td> tags are used to present data in tabular format.
2. A custom tag is defined to generate table and it is used in all the pages. Data which is to be presented in tabular format is provided to the tag as attribute.
From this scenario, you can judge on you own that the second approach is better. It facilitate re-usability and improves productivity.
Custom tags components:
1. Tag Processor: is a server component provided by the tag API, to facilitate processing of custom tags in an application.
2. Tag class: is an application class which contains the tag processing logic. It is defined using the Tag API of JSP.
3. Tag Library Descriptor: is a XML file created by application programmer. It contains the mapping of custom tags and their handler classes. It is used by the Tag processor to identify the Tag classes of the custom tags.
Following diagram describes the processing of a custom tag.