MrBool
You must be logged in to give feedback. Click here to login
[Close]

You must be logged to download.

Click here to login

[Close]

MrBool is totally free and you can help us to help the Developers Community around the world

Yes, I'd like to help the MrBool and the Developers Community before download

No, I'd like to download without make the donation

[Close]

MrBool is totally free and you can help us to help the Developers Community around the world

Yes, I'd like to help the MrBool and the Developers Community before download

No, I'd like to download without make the donation

JSTL Overview: JSP Standard Tag Library

This article will discuss about JSTL(Java Standard Tag Library), which is widely used in most of the MVC framework.

[close]

You didn't like the quality of this content?

Would you like to comment what you didn't like?

JSTL is the part of enterprise edition of java platform and these tags are used in order to replace the scripts of JSP and therefore the expression language is used for that purpose to write the required expressions with the specific syntax provided in EL. In order to access and know about the functionality present in JSTL, there is a need to have the concepts of HTML, Java and JSP. The well formed web pages can be created by the web languages of server side. The web applications written with JSTL can be deployed respectively on the container of JSP that supports the JSTL.

Java Server Pages Standard Tag Library (JSTL) provides many custom tags in the form of a standard set. These custom tags include tags for different purpose and they are for iteration, in order to access the URLs, in order to access the data from the database system, in order to transform and manipulate the documents of XML, for internationalization and the formatting of numbers and date, to control the flow of JSP page, the execution of SQL queries and these functionalities are used by the developers in order to develop the web pages that are fully functional and dynamic.

JSTL is basically a specification, it divides the tags into different groups and available in the form of separate tag libraries in order to use respectively. There is the availability of a URI and a prefix for each tag library. JSTL is much simple and it came in order to make the development and implementation of JSP pages in an easy manner. The groups on which the tags of JSTL have been divided and which made these tags available as the separate tag libraries includes core, XML processing, internationalization and formatting, database access. The core library consists of tags for many uses in order to access the data present in memory and apply the changes needed if any, in order to make the decisions in pages and in order to add the loops over the data. The suggested prefix to be used for core library is c. The XML processing library consists of tags for use of different purpose and this includes parsing the documents of XML, in order to print the parts of this type of documents, in order to make different decisions in the page depending on the content of this document. The suggested prefix to be used for XML processing library is x. The internationalization and formatting library consists of tags that are used in order to read and print the numbers and dates having support of time zones, in order to help the work of application in addition to one language. The suggested prefix to be used for internationalization and formatting library is fmt. The database access library basically helps in order to read and write the data respectively. The suggested prefix to be used for database access library is sql in order to know and get the idea that it is for the purpose of the retrieval and access to database system in a respective manner.

The tag libraries of JSTL can be imported in order to use in page of JSP using the <%@taglib%> directive. The directive tag consists of a specific meaning to the container of JSP. The Expression Language (EL) of JSTL which is a programming language used for specific purpose and can be used to insert the expressions in the webpage. This EL is the part of the specification of JSP and it does not depend directly on the specification of JSP. When there comes any expression, it first gets evaluated by EL and EL is responsible in order to handle the expressions as well as literals and these expressions are represented using the form of $ {expression} respectively.The tags available in JSTL are standard but they come in a separate group.

The <c:out> tag of core library is used mostly in JSTL and this displays the result of an expression on the output screen. The flow control of JSTL is available in two forms which include conditions or the logic of conditions and iteration or loops. The JSTL decision consists of the tags and in order to decide <c:if> is used which gives the answers in the form of yes or no and the other conditions are also available and for that purpose these <c:choose>, <c:when>, c:otherwise> tags are used. The JSTL loops consists of <c:forEach> for generally used loops required and in order to iterate over strings <c:forTokens> is used respectively.

The other tags available in core library includes <c:set>, <c:remove>, <c:catch>, <c:import>, <c:param>, <c:redirect> and <c:url>. The tags available in the formatting and internationalization library include <fmt:formatNumber>, <fmt:parseNumber>, <fmt:formatDate>, <fmt:parseDate>, <fmt:bundle>, <fmt:setLocale>, <fmt:setBundle>, <fmt:timeZone>, <fmt:setTimeZone>, <fmt:message> and <fmt:requestEncoding>. The tags which are present in database access library includes <sql:setDataSource>, <sql:query>, <sql:update>, <sql:param>, <sql:dataParam> and <sql:transaction>.

There are custom tags available in XML processing library and these include the following; <x:out>, <x:parse>, <x:set>, <x:if>, <x:forEach>, <x:choose>, <x:when>, <x:otherwise>, <x:transform> and <x:param>.

Importance:

JSTL is built on top of a server side JSP technology and the JSTL pages are also JSP pages because the work is done inside the JSP page but the tags are separate.JSTL basically helps in order to separate the logic of business from the logic of presentation in an excellent manner. While using JSTL the better and clean code can be written in comparison with JSP. The dynamic content of HTML can be easily created by the proper use of JSTL in the web application. The code of java and HTML gets separated with the use of java server pages standard template library (JSTL) and related custom tags. The robust and easier to maintain the web applications can be created by using these server side technologies which include servlets, JSP and JSTL.

Screenshots:

Web Application

Figure 1: Web Application

The Figure 1 shows the output of web application and Figure-03 display the results when the output comes from the database system using the JSTL tags.

Output of Available Table in Database

Figure 2: Output of Available Table in Database

The Figure 2 shows the output of table and the output of three columns from this will be shown when the application works successfully using JSTL tags of database library and as shown in Figure 3.

JSTL work in JSP Web Application and Output

Figure 3: JSTL work in JSP Web Application and Output

The Figure 3 shows the output of three columns from the table as given in Figure 2.

Implementation & Codes:

Listing 1: index.jsp

<%@ taglibprefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglibprefix="sql" uri="http://java.sun.com/jsp/jstl/sql"%>
<%@pageimport="javax.servlet.jsp.jstl.sql.Result" %>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title style="background-color: khaki;">JSTL work in th JSP Page</title>
</head>
<body>
<h1 style="background-color: orange;">This page of JSP consists of the JSTL and custom tags</h1>
<sql:setDataSource
driver="org.apache.derby.jdbc.ClientDriver"
url="jdbc:derby://localhost:1527/Management"
user="use"
password="system"
var="results"
            />
<sql:setDataSource
dataSource="${results}"
scope="request"/>
<sql:queryvar="results" sql="SELECT C_NAME, C_ADDRESS, C_PROFESSION FROM CUSTOMER"/>
<table border="1">
<thead>
<tr>
<th>Customer Name</th>
<th>Customer Address</th>
<th>Customer Profession</th>
</tr>
<thead>
<tbody>
<c:forEachvar="crows" items="${results.rows}">
<tr>
<td>
                        ${crows.C_NAME}
</td>
<td>
                        ${crows.C_ADDRESS}
</td>
<td> ${crows.C_PROFESSION}   </td>>
</tr>
</c:forEach>
</tbody>
</table>
</body>
</html>

Conclusion:

The index.jsp consists of the tags of JSTL and the code from the working application is given and the output results are according to this code.

Hope you liked it. See you next time.



My main area of specialization is Java and J2EE. I have worked on many international projects like Recorders,Websites,Crawlers etc.Also i am an Oracle Certified java professional as well as DB2 certified

What did you think of this post?
Services
Know how to keep MrBool Online
SUPPORT US
SUPPORT US
With your help, we can keep providing free content and helping you to be a better professional
support us
[Close]
To have full access to this post (or download the associated files) you must have MrBool Credits.

  See the prices for this post in Mr.Bool Credits System below:

Individually � in this case the price for this post is US$ 0,00 (Buy it now)
in this case you will buy only this video by paying the full price with no discount.

Package of 10 credits - in this case the price for this post is US$ 0,00
This subscription is ideal if you want to download few videos. In this plan you will receive a discount of 50% in each video. Subscribe for this package!

Package of 50 credits � in this case the price for this post is US$ 0,00
This subscription is ideal if you want to download several videos. In this plan you will receive a discount of 83% in each video. Subscribe for this package!


> More info about MrBool Credits
[Close]
You must be logged to download.

Click here to login