General Syntax of JSTL Tags

This section describes general syntax of a JSTL tag, which consists of tag namespace, tag name, tag attributes, and tag body.

In general, a JSTL tag is an XML element, which consists of:

Since JSTL tags are XML elements, their syntax is very simple. Here are some examples of different ways of writing JSTL tags in JSP pages:

<!-- no attribute and no body -->
<p:tag/>

<!-- 1 attribute and no body -->
<p:tag attribute="text_only"/>

<!-- no attribute and with body -->
<p:tag>
   xml_body
</p:tag>

<!-- 1 attribute and with body -->
<p:tag attribute="text_only">
   xml_body
</p:tag>

<!-- EL expression as attribute value -->
<p:tag attribute="${expression}">
   xml_body
</p:tag>

<!-- EL Composite expression as attribute value -->
<p:tag attribute="text${expression}text${express}...">
   xml_body
</p:tag>

<!-- tag attribute provided as JSP "attribute" -->
<p:tag attribute="${expression}">
   <jsp:attribute name="attribute">${expression}</jsp:attribute>
</p:tag>

As you can see, there are a number of variations in the syntax:

Examples of JSTL tags:

<c:out value="Hello world!"/>
<c:if test="${1+1==2}">
   Always true.
</c:if>
<c:set var="message" value="Hello world!"/>
<c:out value="${message}"/>

Table of Contents

 About This Book

 JSP (JavaServer Pages) Overview

 Tomcat Installation on Windows Systems

 JSP Scripting Elements

 Java Servlet Introduction

 JSP Implicit Objects

 Syntax of JSP Pages and JSP Documents

 JSP Application Session

 Managing Cookies in JSP Pages

 JavaBean Objects and "useBean" Action Elements

 Managing HTTP Response Header Lines

 Non-ASCII Characters Support in JSP Pages

 Performance of JSP Pages

 EL (Expression Language)

Overview of JSTL (JSP Standard Tag Libraries)

 What is JSTL

 Installing GlassFish JSTL on Tomcat

 "Hello world!" with JSTL

 JSTL in XML Style JSP Pages

General Syntax of JSTL Tags

 NoClassDefFoundError - LoopTag/ForEachTag

 Installing JSTL 1.2 API JAR File

 JSTL Example - Loop Tag on Map Objects

 JSTL Core Library

 JSP Custom Tags

 JSP Java Tag Interface

 Custom Tag Attributes

 Multiple Tags Working Together

 File Upload Test Application

 Using Tomcat on CentOS Systems

 Using Tomcat on macOS Systems

 Connecting to SQL Server from Servlet

 Developing Web Applications with Servlet

 Archived Tutorials

 References

 Full Version in PDF/EPUB