This section provides you the detailed explanation of the Tag Library in JSP. In the Java Server Pages Technology, multiple actions are accessed by using the tags of the JSP whether the tag is standard tag of the JSP or the custom tag that is made by you. Actions in JSP are created for using programming language objects and gives output as you wish. However, you can say that the tag library is a collection of custom tags.
The Tag Library is used in your JSP code for improving the reusability of the JSP code in your JSP application.
Declaring a Tag Library in JSP code:
Tag libraries are declared by using the <%@taglib %> directive of the JSP. This tag has some own attributes and it's values are specified according to the different attributes of the taglib directive. Attributes of the taglib directive are as follows:
uri: This is the attribute of the taglib directive in JSP that contains the absolute and relative URIs for the TLD (Tag Library Descriptor) file which is with the ".tld" extension. This attribute must have the value as Tag Library Descriptor (TLD).
Some absolute URIs are given for the JSTL library are as follows:
For SQL: http://java.sun.com/jsp/jstl/sql
The value of the uri attribute may be absolute or relative if you want to use the taglib directive by specifying the absolute path of the TLD file because uri must have the value as the TLD file. This file must have the extension (".tld"). For example, the declaration of the taglib directive for the core is like <%@taglib prifix="c" uri="http://java.sun.com/jsp/jstl/core" %> otherwise if you want to use the uri attribute of the taglib directive in JSP by specifying the relative URIs then the declaration is like <%@taglib prifix="nameWhatever" uri="/WEB-INF/tldDirectory/tldName.tld" %>.
prifix: This is the attribute of the taglib directive in JSP that is used for naming for the identification of the tag. You can say simply that this attribute of the taglib directive contains the name of the specified Tags or the TLDs for using in your JSP code easily and in efficient manner.
tagdir: This is also a type of the taglib directive in JSP that is used for specifying your customized tags. These customized tags are made by specifying all the action in a file that must have the ".tag" or the ".tld" extension. This is the used in the place of the uri attribute of the taglib directive of JSP. You can use either the uri or the tagdir attribute of the taglib directive in JSP. When you use the tagdir attribute for specifying the tag file then you have to put the tag file in the subdirectory inside the WEB-INF folder in your JSP application directory.JSP Standard Tag Libray (JSTL) and JSP Custom Tag Libray are two standard of tag library which are almost used for implementing the tag library.
Recommend the tutorial