The Core JSTL: The
core tags are used to perform iteration, conditional processing, It can be used
in jsp page by accessing the following library:
< %@ taglib prefix="c" uri="http://
java.sun.com/jstl/core" %>
There are mainly three types of core tags:
-
General purpose tags: It
is used for writing the values to the output stream, and setting and
removing attributes.
- <c:out>: It
evaluates an expression that may be given in its value attribute or in its
tag body. It shows the output.
<c:out attributes> result</c:out>
- <c:set>:It is another general
purpose tag, which allows us to set the value of a variable or property into
the given scop.
<c:set attribute> body</c:set>
- <c:remove>: The
<c:remove> tag allows us to remove the variable from the specified. the
syntax is:
<c:remove attributes/>
- <c:catch>: It
is used to allow jsp pages to handle exception that might be raised by any
of the tag inside the <c:catch>tag.
<c:catch attributes>body content</c:catch>
-
Conditional Looping Tags: It
tags include conditions, switch cases and loops.
Types of conditional and looping tags:
- <c:if>
- <c:choose>
- <c:when>
- <c:otherwise>
- <c:foreach>
- <c:fortoken>
-
Networking Tags: It
is used for the including some other web pages and redirecting the client
request.
Types of Networking Tag:
- <c:import>
- <c:url>
- <c:redirect>
- <c:param>
JSTL SQL Tags : The
Sql tag library is used to access the relational data base used in jsp pages.
Types of SQl Tag:
-
<sql:query tag>: It
executes the query specified in the Sql attribute or in the tag body. Syntax for
the query tag:
<sql:query attributes> body</sql:query>
-
<sql:update tag>: The result of the query
is set to the variable specified in the var attribute.
<sql:update attributes>body</sql:update>
-
<sql:param tag>:It is used to set a
parameter in the Sql statement.
<sql:param attributes>body</sql:param>
-
<sql:dateparam>: It
is used to set a date parameter in the Sql statement.
<sql:dateparam attributes/>
-
<sql:setDataSource>:It is used for binds
a data source to the specified variable.
JSTL Formatting Tags:
The format tag library provides support for
internationalization. This provide formating of data in different domain. The
data can be numbers, or the time specifications in different domains. It is used
as:
<%taglib prefix="fmt:uri="http://java.sun.com/jsp/jstl/fmt"
%>
There are four types of JLST formating Tag:
-
Basic formatting tags
-
Number formatting tags
-
Date formatting tags
-
Time Zone tags
JSTL XML Tags:
The XML Tag library is used to work with XML data
used in the jsp pages. The XML tag library helps parse and transform the data
used in the jsp page.
The syntax for this tag is:
<%@taglib prefix="x" uri="http://java.sun.com/jsp/jstl/xml"
%>
XML tags are also categorized into following
categories:
-
XML Core tags: It include the tags for
parsing xml documents and performing operations. There are three types:
- <x:parse>
- <x:out>
- <x:set>
-
XML Flow Control Tags: It
is used for the easily parse and access xml data, iterate over elements in an
xml document.
There are five tags in contains:
-
<x:if>
-
<x:choose>
-
<x:when>
-
<x:otherwise>
-
<x:forEach>
-
XML Transformation Tags: This
is used for the providing the support to transform the xml document with the
given xsl stylsheet. This part also contain two parts:
-
<x:transform>: It tansform an xml
document using the given XSL style sheet.
Syntax : <x:transform attributes>body</x:transform>
-
<x:param>: It is used to set
transformation parameters. It should be used within the body of the <x:transform>tag.
Syntax : <x:param attributes> body </x:param>
Example 1.