JSP Standard Tag Library(JSTL)

Sanskruti's Avatar author of JSP Standard Tag Library(JSTL)
This is an article on JSP Standard Tag Library(JSTL) in Java.
JSTL is a collection of tags similar to HTML that lets you produce dynamic web pages without needing to learn Java.

Why JSTL?



JavaServer Pages (JSP) technology makes it easy to embed bits of Java code (or scriptlets) in HTML documents. This solution, however, may not be suitable for all HTML content developers, perhaps because they may not know Java. To serve these HTML developers, you can introduce custom tags through the JSP Standard Tag Library, which can be deployed and used in an HTML-like syntax.

Custom tags provide a way to reuse valuable components. The typical problem with custom tags, however, is that they still need to be created, tested, and debugged. In addition, developers often have to reinvent the wheel over and over again and the solutions may not be the most efficient. This is the problem that the JavaServer Pages Standard Tag Library solves, by providing a set of reusable standard tags. JSTL defines a standard tag library that works the same everywhere, so you no longer have to iterate over collections using a scriptlet (or iteration tags from numerous vendors). For example, a Java developer might write a method to determine a user's first name and then expose this code using a tag called <user:firstName>. Whenever this tag appears, the developer's back-end logic would run and produce the user's first name; it would then insert this name into the web page's output. So a page author could write the following:

HTML Code:
<p>
    Dear <user:firstName/>,
</p>
and produce dynamic content, very much like the age-old word-processing practice of mail merge.

JSTL: Standard tags



As JSP grew in popularity, it became clear that different sites' custom tags fell into familiar, frequently used patterns. For example, many pages needed to loop over data to print tables and lists. Other pages accessed information from databases, or retrieved information stored in XML files.

Vendors of JSP containers and members of the open-source community tried to address these needs by providing collections of tags -- tag libraries -- that solved common problems. For instance, JRun, the popular JSP container, began to provide a proprietary tag library of its own, and the Jakarta Taglibs project offered free libraries for tasks like XML manipulation, HTML form generation, and database access.

While many JSP page authors used these libraries, nothing tied them together. For instance, you couldn't count on your favorite tag library being available if you moved from one project to another. One site might use Jakarta Taglibs, another would depend on JRun's library, and a third could rely on custom tags produced and maintained locally. To address this fragmentation, the Java Community Process -- the same group that now maintains and standardizes JSP itself -- decided to offer a standard tag library. JSTL, this includes tags for the following common tasks:
  • looping over data to produce tables, lists, etc. (e.g., "print all of the user's orders")
  • conditional operations
  • importing and processing data from other other web pages
  • simple XML manipulation
  • database access
  • text formatting and internationalization
rexonery's Avatar, Join Date: Feb 2009
Newbie Member
how do i get free books for download on jsp
bapsbps's Avatar, Join Date: Mar 2009
Newbie Member
JSTL is nothing but Java standard Tag Library which is mainly used when we using struts.Now a days almost maximum programmers are using struts in that struts framework we are using JSTL.JSTL's are mainly own derived tags using java.
JavaServer Pages (JSP) technology makes it easy to embed bits of Java code (or scriptlets) in HTML documents. This solution, however, may not be suitable for all HTML content developers, perhaps because they may not know Java. To serve these HTML developers, you can introduce custom tags through the JSP Standard Tag Library, which can be deployed and used in an HTML-like syntax.