Java Reference
In-Depth Information
LISTING 21.14
The full text of rss.jsp
1: <!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.0 Transitional//EN”>
2: <html>
3: <head>
4: <!-- Declare the two tag libraries used on this page -->
5: <%@ taglib uri='http://java.sun.com/jsp/jstl/core' prefix='c' %>
6: <%@ taglib uri='http://java.sun.com/jsp/jstl/xml' prefix='x' %>
7:
8: <!-- Import the RSS feed at the URL specified by feed -->
9: <!-- For example -->
10: <!-- http://sportsfilter.com/rss.cfm -->
11: <c:import url='${param.feed}' var='feedData'/>
12:
13: <!-- Parse the RSS feed -->
14: <x:parse xml='${feedData}' var='feed'/>
15:
16: <!-- Retrieve the channel element -->
17: <x:set select='$feed//rss//channel' var='channel'/>
18:
19: <!-- Display the channel element's title -->
20: <title><x:out select='$channel//title'/></title>
21: </head>
22:
23: <body>
24:
25: <!-- Display the channel element's link and title -->
26: <p>Headlines from <a href=”<x:out select='$channel//link'/>”>
27: <x:out select='$channel//title'/></a>
28:
29: <!-- Loop through the item elements -->
30: <p><ul>
31: <x:forEach select='$feed//rss//channel//item'>
32: <!-- Display each element's link, title, description -->
33: <!-- Descriptions may contain HTML. -->
34: <li><a href=”<x:out select='link'/>”><x:out select='title'/></a>:
35: <x:out select='description' escapeXml='false'/></li>
36: <br>
37: </x:forEach>
38: </ul>
39:
40: </body>
41: </html>
21
Comments on the page describe the JSTL actions that it contains.
The most challenging part of JSTL is the Expression Language, which can be avoided by
using versions of the tag libraries that use JSP syntax for Java statements and expres-
sions.
 
Search WWH ::




Custom Search