JSP Taglib directive

A user can customize actions from their tag file using the Tag Lib directive.We use the TLD (Tag Library Descriptor) file to define the tags. The Tag Lib directive is a collection of custom tags.

The syntax of Tag Lib directive is:

<%@ taglib uri = "tag library URI" prefix = "tag	Prefix" %> 
		

In the above, taglib and uri are both keywords. The URI, which can be absolute or relative, uniquely identifies the tag library descriptor and is enclosed with " " in tag library URI. The tag prefix included inside " " is a string that will become the prefix to distinguish a custom action

Example of JSP Taglib directive

In this example, we are using our tag named currentDate. To use this tag we must specify the taglib directive so the container may get information about the tag.

<html>
<body>

<%@ taglib uri="http://www.javatportal.com/tags" prefix="mytag" %>

<mytag:currentDate/>

</body>
</html>