JSP JSTL Tutorial

JSP JSTL Tutorial


Posted in : Java Posted on : March 28, 2012 at 7:44 PM Comments : [ 0 ]

In this tutorial you will learn about the JSTL (Java Standard Tag Library).

JSP JSTL Tutorial

In this tutorial you will learn about the JSTL (Java Standard Tag Library).

In JSP Java Standard Tag Library included a various different useful tags that belongs to the basic requirement or functionality to the discrete jsp applications. The benefit for using a JSTL over a vendor-specific tag library is that you can deploy your application on any JSP container. Using JSTL you can employ a single, standard set of tags. JSTL provides the various utility tags such as  for iterating, for handling the flow control, to manipulate the xml documents, to access the database and the various functions. Using tags and functions provided by JSTL on a JSP page logic can be embedded without writing a full java code directly. On behalf the previous line we can say that according to the functional area, tags in JSTL can be classified into the different JSTL tag library so the JSTL is exposed through multiple Tag Library Descriptor in which each of the TLD have its own namespace, or prefix these are as follows :

  • JSTL core : core library (Core tags)
  • JSTL fmt : i18n-capable formatting library (Formatting tags)
  • JSTL sql : sql library (SQL tags)
  • JSTL XML : XML library (XML tags)
  • JSTL functions : functions library (JSTL functions)

To include the above tag libraries you have to use the <%@ taglib /> directive with their respective "uri" and "prefix". for example :

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

In the table given below describes the tag libraries with their respective "uri", "subfunction" and "prefix" values.

Tag Library URI Subfunction Prefix
JSTL core http://java.sun.com/jsp/jstl/core Variable support, Flow control, URL management, Miscellaneous c
JSTL fmt http://java.sun.com/jsp/jstl/fmt Locale, Message formatting, Number and date formatting fmt
JSTL sql http://java.sun.com/jsp/jstl/sql SQL sql
JSTL functions http://java.sun.com/jsp/jstl/functions Collection length, String manipulation fn

NOTE : You would be required the jstl.jar, standard.jar files to use the JSTL

Some of the tag examples of each tag library are as follows :

Core tags : (Click here to jstl core tag library tutorial)

1. <c:forEach></c:forEach> tag is used for iterating functionality.

2. <c:if></c:if> tag is used for evaluating the conditional statement when if is 'true' etc.

Formatting tags :(Click here to jstl fmt tag library tutorial)

1. <fmt:formatDate></fmt:formatDate> tag is used for formatting the date/time.

2. <fmt:setLocale></fmt:setLocale> tag is used for storing the Locale. etc.

Functions :(Click here to jstl functions library tutorial)

1. { fn:toUpperCase() }tag is used to change a string written in lower case to upper case.

2. { fn:contains() } tag is used to test whether the string that is inputted is contained a substring or not. etc.

SQL tags :(Click here to jstl sql library tutorial)

1. <sql:query></sql:query> tag is used to execute the sql query defined in its body.

2. <sql:param></sql:param> tag is used to set the parameter to a defined value in a SQL statement. etc.

XML tags :(Click here to jstl xml library tutorial)

1 <x:parse></x:parse> tag parses the XML data.

2. <x:out></x:out> tag is used to display the output of an Xpath expression.

Go to Topic «PreviousHomeNext»

Your Comment:


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 

 
Tutorial Topics