Taglib Directive
The taglib directive is used to define tag library that the current JSP page uses. A JSP page might include several tag library. JavaServer Pages Standard Tag Library (JSTL), is a collection of useful JSP tags, which provides mahy commonly used core functionalities. It has support for many general, structural tasks such as iteration and conditionals, readymade tags for manipulating XML documents, internationalization tags, and for performing SQL operations. Syntax of taglib directive is:
<%@ taglib prefix="prefixOfTag" uri="uriOfTagLibrary" %>
The prefix is used to distinguish the custom tag from other libary custom tag. Prefix is prepended to the custom tag name. Every custom tag must have a prefix.
The URI is the unique name for Tag Library.
You can name the prefix anything, but it should be unique.
Using Taglib Directive
To use the JSTL in your application you must have the
jstl.jar
in your webapps /WEB-INF/lib
directory. Download the jar file from Apache Standard Taglib page.
There are many readymade JST Libraries available which you use to make your life easier. Following is a broad division on different groups of JST libraries :
- Core Tags - URI → http://java.sun.com/jsp/jstl/core
- Formatting Tags - URI → http://java.sun.com/jsp/jstl/fmt
- SQL Tags - URI → http://java.sun.com/jsp/jstl/sql
- XML Tags - URI → http://java.sun.com/jsp/jstl/xml
- JSTL Functions - URI → http://java.sun.com/jsp/jstl/functions