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.

Jsp Taglib Directive

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 :

  1. Core Tags - URI → http://java.sun.com/jsp/jstl/core
  2. Formatting Tags - URI → http://java.sun.com/jsp/jstl/fmt
  3. SQL Tags - URI → http://java.sun.com/jsp/jstl/sql
  4. XML Tags - URI → http://java.sun.com/jsp/jstl/xml
  5. JSTL Functions - URI → http://java.sun.com/jsp/jstl/functions

You can check the complete JST Library here : Apache Standard Taglib API