Custom tag libraries
A custom tag library is a set of custom tags that invoke custom actions in a JSP file. Tag libraries reduce the task of embedding excessive amounts of Java™ code in JSP pages by moving the functionality provided by the tags into tag implementation classes.
Tag libraries are usually created by developers who are proficient in the Java programming language and can be used by Web designers who might not know Java, but would like to enhance their Web site by taking advantage of Java encoded tag libraries.
Tag libraries offer the following benefits:
- Help separate presentation from implementation.
- Are easy to maintain and reuse
- Simplify complex actions
- Provide Java-coded functions without the task of coding in Java.
- Can dynamically generate page content and implement a controlled flow.
You can develop tag libraries yourself or you can download them from existing open-source utility tag libraries from sites such as the Jakarta Project, a division of the Apache Software Foundation. Jakarta offers an excellent tag libraries tutorial on the site as well.
In the Design tab of Page Designer, visualizations of JSP Custom tags are provided by Eclipse plugins These Eclipse plugins implement a Visual Custom Tag extension to provide this visualization. See Creating visual custom tags (VCTs) to find out more about creating an Eclipse plugin to provide visualizations for a specific JSP custom tag library.
This product includes the JavaServer Pages Standard Tag Library (JSTL), a library of custom tags that provide the core functionality common to many Web applications. If you have included the JSF and JSTL project facets in your project, you can select and insert a particular tag from the tag library when you edit the JSP. (To insert a custom tag, right click in the JSP and select
JSP | Insert Custom)
You can add the JSTL library to a project when you create the project by selecting the JSTL project facet in the New Dynamic Project wizard.
Note: If you did not include JSTL when you first created the project, you can add it afterwards by selecting
Project | Properties | Project Facets .
The
web.xml
file provides the link between the directive used in the application and the actual JAR file containing the classes that execute the function.
Related tasks
Adding the Tag Library Descriptor (TLD) file
Adding a taglib directive to a JSP file
Specifying the taglib directive
Adding a custom tag to a JSP file
Editing the properties of a custom tag
Editing a Web deployment descriptor file for a custom tag library
Related reference