JSTL Overview

  • Facebook
  • Google
  • LinkedIn
  • Twitter

JSP Standard Tag Library (JSTL) is a standard library of custom tags using these tag you can remove scriplet code from a JSP page and these tags and functions will help in writing JSP code efficiently. JSTL support tasks such as iteration, conditionals, internationalization tags, and SQL tags.

Advantages of JSTL:

  1. Code reusability you can use all JSTL tags in your application on multiple pages
  2. Scriplet tags are not needed on the jsp page.
  3. You can make project very fast using JSTL.

Here are following types of JSTL tags:

1. JSTL Core Tags:

It provides tags such as if, forEach, import, out etc. You can easily use these tags in the jsp page where you need. Here is the syntax of JSTL Core Tag which needs to include in the JSP page.

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

2. JSTL SQL tags:

It provides connectivity support with relational databases such as Oracle, MySql etc. Using these tags you can run database queries. Here is the syntax of JSTL SQL tags which needs to include in the JSP page.

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

3. JSTL Formatting tags:

These tags are used to format and display text, date, time and numbers for internationalized Web sites. Here is the syntax of JSTL Formatting tags which needs to include in the JSP page.

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

4. JSTL XML tags:

It provides XML support and flow control, transformation etc. Here is the syntax of JSTL XML tags which needs to include in the JSP page.

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

5. JSTL Functions:

It provides string manipulation support. Here is the syntax of JSTL Function tags which needs to include in the JSP page.

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

So you need to download the JSTL jars and include these libraries in your web application project WEB-INF/lib directory if your project is maven based then below dependencies should be added in pom.xml file.

<dependency>
	<groupId>jstl</groupId>
	<artifactId>jstl</artifactId>
	<version>1.2</version>
</dependency>
<dependency>
	<groupId>taglibs</groupId>
	<artifactId>standard</artifactId>
	<version>1.1.2</version>
</dependency>
For more details please see
Oracle Java SE Documentation
      Advertisements