The JSP library has a collection of useful JSP tags, responsible and functionally capable of encapsulating the core utilities typically found in a JSP application. JSTL, known as JSP Standard Tag Library, is a set of tags. This helps make coding in JSP much easier and simplifies the JSP development process. In this lesson, you will learn how to start using this JSP standard library and its various methods and tags.
What Is JSTL?
JSTL, abbreviated as Java Server Pages Standard Tag Library, can be defined as a group of different custom JSP tag libraries used to provide common web development functionality to JSP developers.
Advantages of JSTL
Here is a list of advantages that this JSTL provides:
- Neat and Clean Coding approach: Since scripts confuse developers a bit, their usage can be replaced with JSTL, making coding easier.
- Standard Tag: JSTL provides an affluent layer of manageable functionality in your JSP pages. This makes the JSP code easier to understand.
- Automatic Support of Javabeans Introspection: It is also beneficial to use JSTL over JSP's normal scriptlet. The JSTL Expression language is efficient in handling JavaBean code. Downcasting of objects is not required, which can also be retrieved as scoped attributes. JSP scriptlet generates a range of complicated codes, but JSTL has cut down to ease that.
- Easy for computers to understand: There are applications like Dreamweaver and front page, which generate more and more HTML code. In such tools, the HTML code gets mixed with the JSP scriptlet code in the back end of the development. However, since JSTL is expressed as an XML yielding tag, it becomes easy for HTML generation in parsing these JSTL codes without many hurdles within your document code.
- Easier for humans to read: JSTL is XML based custom tags similar to that of HTML. Hence, this makes it easy for developers to read and understand.
Tag Categories in JSTL
There are mainly five categories of JSTL tags under the standard tag library of JSP:
- Core tags: Core tags have variable support, flow control, URL management, etc. The URL used in the core tag is http://java.sun.com/jsp/jstl/core. These tags are prefixed with a 'c' followed by a colon and then the tag name.
- Function tags: Function tags holds a collection of standard function. The URL used in this function tag is http://java.sun.com/jsp/jstl/functions. These tags are prefixed by an 'fn' followed by a colon.
- Formatting tags: Formatting tags give support to format the messages, numbers, and dates, etc. Its URL is http://java.sun.com/jsp/jstl/fmt. It is prefixed with a 'fmt' followed by a colon.
- XML tags: XML tags offer a flow control mechanism, transformation, and some other features. Its URL is http://java.sun.com/jsp/jstl/xml. It is prefixed with a 'x' followed by a colon.
- SQL Tags: SQL Tags offers SQL support. The URL is http://java.sun.com/jsp/jstl/sql. It is prefixed with a 'SQL' followed by a colon.