.


Divya

JSP Taglib Directive


To define a tag library that defines many tags, JSP taglib directive is used. We use the TLD (Tag Library Descriptor) file to define the tags.

The URI is the unique name for Tag Library.

Syntax JSP Taglib directive

<%@ taglib uri="uriofthetaglibrary" prefix="prefixoftaglibrary" %>

Example

For example, suppose the custlib tag library contains a tag called hello. If you wanted to use the hello tag with a prefix of mytag, your tag would be <mytag:hello> and it will be used in your JSP file as follows:

<%@ taglib uri="http://www.example.com/custlib" prefix="mytag" %>
<!DOCTYPE html>
<html>
<body>
<mytag:hello/>
</body>
</html>

The JS API allows you to define custom JSP tags that look like HTML or XML tags and a tag library is a set of user-defined tags that implement custom behavior.



.