Ques : What is taglib Directive ?

Ans :

As yet, you have learned the basic elements of JSP. In this section, you will learn about the
creation of custom tag libraries in Java Server Pages.

A custom tag is user defined tag. It is a reusable code in a JSP page and tag library is a
collection of custom tags.

Custom Tag Syntax –

To use the customs tags in a JSP page, JSP technology provide a taglib directive to make use
of the tag. The taglib directive has the following syntax:

To use the customs tags in a JSP page, JSP technology provide a taglib directive to make use
of the tag. The taglib directive has the following syntax:

<%@ taglib uri=”tagLibraryURI” prefix=”tagPrefix” %>

The uri attribute defines an absolute or relative uri of tag library descriptor (TLD) file and the
prefix attribute defines the string that will identify a custom tag instance.

To use customs tags in a JSP page, you need to know four components that make use of the
custom tags. These are:
1) Tag handler class
2) Tag library descriptor file
3) JSP file
4) Deployment descriptor file (web.xml)

Leave a Reply