Java Reference
In-Depth Information
headerValues , a collection of all request headers, each as a string array
n
initParam , a collection of all application initialization parameters, each as a string
n
pageContext , an instance of jspPageContext from the javax.servlet package
n
param , a collection of all request parameters, each as a string
n
paramValues , a collection of all request parameters, each as a string array
n
When using one of these collections or other data structures, the c:foreach action makes
it easy to loop through each element. The following example displays all of the header
variables sent with a JSP page:
<c:forEach items='${header}' var='head'>
<ul>
<li>Name: <c:out value='${head.key}'/></li>
<li>Value: <c:out value='${head.value}'/></li>
</ul>
</c:forEach>
Four variables can be used to make explicit references to variable scope:
applicationScope , a collection of all application scope objects
n
pageScope , a collection of all page scope objects
n
requestScope , a collection of all request scope objects
n
sessionScope , a collection of all session scope objects
n
For example, the expression ${sessionScope.price} retrieves an object named price in
session scope. If no other scope has an object named price , the expression ${price}
also works.
Today's final project shows some of the power and flexibility of JSTL. This page makes
use of XML actions to present data from an RSS newsfeed, an XML format for offering
web content in machine-readable form.
JSTL can import and parse XML, HTML, or any other data available at a URL, even if it
isn't on the same server as the page making use of it.
RSS, which stands for Really Simple Syndication, enables websites to share headlines,
links, and other content with each other (and with readers using software called an RSS
aggregator). Listing 21.13 contains an example: a simplified version of the RSS feed for
the SportsFilter website.
21
Search WWH ::




Custom Search