JSP Tutorials - Herong's Tutorial Examples - v5.11, by Herong Yang
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
JSP (JavaServer Pages) Overview
Tomcat Installation on Windows Systems
Syntax of JSP Pages and JSP Documents
JavaBean Objects and "useBean" Action Elements
Managing HTTP Response Header Lines
Non-ASCII Characters Support in JSP Pages
►Overview of JSTL (JSP Standard Tag Libraries)
Installing GlassFish JSTL on Tomcat
NoClassDefFoundError - LoopTag/ForEachTag
Installing JSTL 1.2 API JAR File
JSTL Example - Loop Tag on Map Objects
Multiple Tags Working Together
Using Tomcat on CentOS Systems
Connecting to SQL Server from Servlet