Table of Contents:

        1.Core Tags

        2.Formatting Tags

        3.SQL Tags

        4.XML Tags

        5.JSTL Tag Reference Sample Application

        6.Download Eclipse project/WAR file

 

A comprehensive reference of JSTL tags:

The following sections discuss in details the four types of tag libraries along with examples which are applicable. Please click on each tag to access information about tag usage and working examples.

 

JSTL Core Tags:

 

<c:catch>

 

 

<c:choose>

 

<c:forEach>

 

<c:forTokens>

 

<c:otherwise>

 

<c:out>

 

<c:param>

 

<c:redirect>

 

 

<c:url>

 

<c:when>

 

 <c:if>

 

<c:import> 

 

 

<c:remove>

<c:set>

 


 

 
 

To use core tags in the JSP specify the following directive at the beginning of the JSP.

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
 

JSTL Formatting Tags:

 

<fmt:bundle>

 

 

<fmt:formatDate>

 

<fmt:message>

 

 

<fmt:param>

 

<fmt:parseNumber>

 

 

<fmt:requestEncoding>

 

<fmt:setLocale>

 

 

<fmt:setTimeZone>

 

 <fmt:formatNumber>

 

<fmt:parseDate>

 



  <fmt:timeZone>

 

 <fmt:setBundle>

 

To use formatting tags in the JSP specify the following directive at the beginning of the JSP.

<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
 

JSTL SQL Tags:

 

<sql:dateParam>

 

 

<sql:param>

 

<sql:setDataSource>

 

 

<sql:transaction>

 

<sql:query>

 

<sql:update>

 

 

To use the SQL tags in the JSP specify the following directive at the beginning of the JSP.

<%@ taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql" %>
 

JSTL XML Tags:

 

<x:choose>

 

 

<x:forEach>

 

<x:if>

 

<x:otherwise>

 

<x:parse>

 

 

<x:set>

 

<x:transform>

 

<x:when>

 

<x:out>

 

<x:param>

 


 

 
 

To use the XML tags in the JSP specify the following directive at the beginning of the JSP.

<%@ taglib prefix="x" uri="http://java.sun.com/jsp/jstl/xml" %>
  

JSTL Tag Reference - Sample Application:

The sample Eclipse project contains the working examples for all the four types of JSTL tags. The Eclipse project structure is shown below:

eclipse-project-structure

The project’s starting point is /JSTL-Reference/jstl-tag-reference.jsp. If you’ve deployed this web application in your local Tomcat, the URL to access the JSTL Reference web application is:

http://localhost:8080/JSTL-Tag-Reference/jstl-tag-reference.jsp

 

The Employee.sql contains the database table script used in this project.

jstl-tag-reference

Once you deployed the WAR file to the server, please click on respective tag type to access the full table of contents for each tag type selected. The four following screen captures display each tag type access pages and their respective tags.

core-tag-reference

 

JSTL Core Tags - http://localhost:8080/JSTL-Tag-Reference/tag-types/core-tag-reference.jsp

format-tag-reference

 

JSTL Formatting Tags - http://localhost:8080/JSTL-Tag-Reference/tag-types/formatting-tag-reference.jsp

sql-tag-reference

 

JSTL SQL Tags - http://localhost:8080/JSTL-Tag-Reference/tag-types/sql-tag-reference.jsp

 

[Please ensure the database server is up and running when accessing JSTL SQL tags].

xml-tag-reference

 

JSTL XML Tags - http://localhost:8080/JSTL-Tag-Reference/tag-types/xml-tag-reference.jsp

 

Download Eclipse Project / WAR file

 Please download Eclipse project and deployable .war file in the attachments section.

 

Other JSTL Tutorials:


About the Author:

is certified Java programmer (SCJP and SCWCD). He started programming with Java in the time of Java 1.4 and has been falling in love with Java since then. Make friend with him on Facebook and watch his Java videos you YouTube.



Attachments:
Download this file (JSTL-Tag-Reference.war)JSTL-Tag-Reference WAR File[This .war file is deployable to access working examples from this article.]4039 kB
Download this file (JSTL-Tag-Reference.zip)JSTL Tag Reference Eclipse Project[This Eclipse project can be readily imported into Eclipse environment.]4048 kB