3.1. Using JSTL
Problem
You want to use the JSP Standard Tag Library (JSTL) tags in your Struts application.
Solution
Download the Jakarta Taglibs JSTL reference implementation from http://jakarta.apache.org/taglibs. Copy the jstl.jar and standard.jar files from the lib folder into your applications WEB-INF/lib folder. Then copy the c.tld, fmt.tld, sql.tld, and x.tld files from the tlds folder into your applications WEB-INF/lib folder.
Use the appropriate taglib directives on JSP pages
where you want to use JSTL:
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
Table 3-1 lists the JSTL tag libraries and the corresponding URIs.
Table 3-1. JSTL tag library URIs
|
Tag library |
JSTL 1.0 Taglib URI |
JSTL 1.1 Taglib URI |
|---|---|---|
|
Core | ||
|
Formatting | ||
|
SQL | ||
|
XML | ||
|
Functions |
N/A |
Discussion
JSTL is a powerful set of tag libraries that should be a part of any Struts developer's toolkit. JSTL contains tags for outputting JavaBean properties, looping, conditional logic, and URL formatting. There are tags for formatting and parsing dates and numbers. The XML tag library can be used to parse and process XML on a JSP page. The tags of the SQL tag library interact with a relational database. The ...