JSP taglib Directive
JSP taglib Directive
- Using JSP API’s we can define custom JSP tags like HTML or XML tags.
- JSP tag library is a set of user-defined tags which are used for the implementation of the custom behavior.
- JSP taglib directive is used to -
- Declare set of custom tags
- Identify the location of the library
- Provide a way for identifying the custom tags
Syntax :
We can write taglib directive using below syntax -
<%@ taglib uri="uri" prefix="tagPrefix" >
Attribute | Purpose |
---|---|
uri | Used to define the URL of the TAG library |
prefix | Used to define the prefix of the TAG library |
XML equivalent syntax -
<jsp:directive.taglib uri="uri" prefix="tagPrefix" />
Example :
Suppose the userlibrary tag library contains a tag called print. We can use the hello tag with a prefix of mytag, using syntax
<%@ taglib uri = "http://www.c4learn.com/userlibrary" prefix = "mytag" %> <html> <body> <mytag:print/> </body> </html>