Java Server Pages Standard Tag Library (JSTL) - JEE
Home » JEE, Jsp, Tech Notes

Java Server Pages Standard Tag Library (JSTL)

16 April 2009 One Comment

Along with JSP technology, Sun offered a standard tag library called JavaServerPages Standard Tag Library (JSTL). In the previous article on custom tags, we have gone through the advantages of using custom tags. This tag library provides all those standard tags that will lead to any kind of javascript in the JSP. This tag library also covers conditionals, iterators, XML document manipulation tags, internationalization and DB access tags. These tags are grouped in following categories

  • Core
  • XML
  • Internationalization
  • SQL
  • Function

Using JSTL:

This tag library can be used in the same way as any other custom tag library. Jsp using this custom tag will look like this.

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<html>
<head>
<title>Custom Tag Example</title>
</head>
<jsp:useBean id="customer" scope="page" class="com.myorg.jsptutorial.Customer"></jsp:useBean>
<body>
  <h1><c:out value="${customer.name}"/></h1>
</body>
</html>

First, we are using the taglib directive to declare the tag library. Next is the prefix=”c”, this is used to make a call to the tag library through tag <c:out…./>. This tag just prints value of the customer object’s name attribute. It calls getName() method on this object.

Now let us look at the details of each of the above tag library.

Core:

XML:

  • Uri – http://java.sun.com/jsp/jstl/xml
  • Prefix – x
  • Used for core, flow control and transformation of xml

Internationalization:

  • Uri – http://java.sun.com/jsp/jstl/fmt
  • Prefix – fmt
  • Used for internationalization tasks like locale, message formatting, number and date formatting.

SQL:

  • Uri – http://java.sun.com/jsp/jstl/sql
  • Prefix – sql
  • Used for database interaction related tags.

Function:

  • Uri – http://java.sun.com/jsp/jstl/functions
  • Prefix – fn
  • Used for few functions on collection and string.

<<Previous   Home   Next>>

 

More Related Posts in JEE, Jsp, Tech Notes

One Comment »

  • Sarath Chandra Kumar said:

    please provide more information on JSP and J2ME.

Leave your response!

Add your comment below, or trackback from your own site. You can also subscribe to these comments via RSS.

Be nice. Keep it clean. Stay on topic. No spam.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

This is a Gravatar-enabled weblog. To get your own globally-recognized-avatar, please register at Gravatar.