The JavaServer Pages Standard Tag Library (JSTL) is a collection of useful JSP tags which encapsulates core functionality common to many JSP applications.
JSTL has support for common, structural tasks such as iteration and conditionals, tags for manipulating XML documents, internationalization tags, and SQL tags. It also provides a framework for integrating existing custom tags with JSTL tags.
The JSTL tags can be classified, according to their functions, into following JSTL tag library groups that can be used when creating a JSP page: 1. Core Tags 2. Formatting tags 3. SQL tags 4. XML tags 5. JSTL Functions
Install JSTL Library:
If you are using Apache Tomcat container then follow the following two simple steps: 1. Download the binary distribution from Apache Standard Taglib and unpack the compressed file. 2. To use the Standard Taglib from its Jakarta Taglibs distribution, simply copy the JAR files in the distribution's 'lib' directory to your application's webapps\ROOT\WEB-INF\lib directory.
To use any of the libraries, you must include a <taglib> directive at the top of each JSP that uses the library.
Core Tags:
The core group of tags are the most frequently used JSTL tags. Following is the syntax to include JSTL Core library in your JSP: <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> |
There are following Core JSTL Tags: Tag | Description | <c:out > | Like <%= ... >, but for expressions. | <c:set > | Sets the result of an expression evaluation in a 'scope' | <c:remove > | Removes a scoped variable (from a particular scope, if specified). | <c:catch> | Catches any Throwable that occurs in its body and optionally exposes it. | <c:if> | Simple conditional tag which evalutes its body if the supplied condition is true. | <c:choose> | Simple conditional tag