Helping ordinary people create extraordinary websites!
HOME TUTORIALS SCRIPTS WEB HOSTING BLOG FORUM
Get Our Newsletter
Email:

Grab Headlines From A Remote RSS File

By Nicholas Chase
2003-12-19


The Basic JSP Page

Any number of ways of transforming XML data exist. In this article, I'll show you how to create a JSP page that passes a feed to a Java bean for transformation. That bean creates a static file, and the JSP page incorporates it into the body of the page. (The reason for the static file will become clearer in the caching section below.)

The page itself is fairly straightforward:

Listing 4. The JSP page
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<jsp:useBean id="rssBean" scope="request" class="RSSProcessor">
<%
rssBean.setRSSFile(
"http://wolk.datashed.net/users/adam@curry.com/curryCom.xml");
%>
</jsp:useBean>


<html>
<head>
<title>Syndicated Feeds</TITLE>
</head>
<body>
<jsp:include page="headlines.html" flush="true"/>
</body>
</html>


Here you're simply creating an instance of the RSSProcessor class. Because you've included it in the useBean element, the setRSSFile() method executes when the object is created. This method creates the headlines.html page that the JSP page then incorporates into the output.

Next, create the bean to do the transformation.

Tutorial Pages:
» Retrieve Syndicated Content, Transform It, & Display The Result
» The Source File
» The Primary Stylesheet
» The Basic JSP Page
» Transforming The File
» Adjusting For Multiple Formats
» Choosing A Version
» Caching The Feed
» Conclusion
» Resources


First published by IBM developerWorks


Related Tutorials:
» Starting with XML
» Performing Client-Side XSL Transformations
» Create a Google Sitemap for your Web Site
» XML and Scripting Languages
» Parsing Comma-Separated Values
» XML Security Suite: Increasing the Security of E-Business