JSP Taglib Directive


JSP Taglib Directive:

If a JSP page uses one or more custom tag libraries, then it needs to use the taglib directive to specify the path of the tag library. Teh taglib directive takes two attributes as input – uri and prefix.

<@taglib uri=”/mathLibraryTags” prefix=”m”%>

In the above example TLD file of the tag library is specified by the /mathLibraryTags url. The is specified via the uri attribute of taglib directive. All tags in the tag library can be accessed in the JSP page by using the prefix m specified in the taglib directive. So if there is a tag called sqrt in mathLibaryTags tag library, then jsp file can access the same using <m:sqrt …> element.


Like it? Please Spread the word!