What is Taglib directive?

Defines the tag libraries available in jsp. It allows a jsp page to work with custom tag libraries.
<%@taglib attribute=””%>
The attribute can be,
uri:
Either an absolute or relative url specification that uniquely identifies the TLD associated with the prefix.
tagdir:
It specifies the directory to indicate to the container that it should evaluate any tag files that may be present. The TLD present in the specified directory is used.
prefix:
It defines the prefix String that is used to access the tags(or actions) defined in the tag library.

A translation error occears if the container can not locate the TLD that is specified in the uri.
Example:
<%@taglib prefix=”mytag” tagdir=/WEB-INF/tags”%>
<mytag:use/>

No comments:

Post a Comment