.
Developer Spot - Web Development Tutorials
arrowDeverloper Spot  Tutorials  XML  Grab Headlines From A Remote RSS File 
 
Development Tutorials
ASP
CGI & Perl
CSS
HTML
Java
JavaScript
Linux
PHP
XML




More Resources
Web Hosting Articles
Web Development News
PHP Manual
Web Hosting Directory
Budget Web Hosting Linux Web Hosting Small Business Hosting
Windows Web Hosting Reseller Web Hosting Web Hosting Articles

Grab Headlines From A Remote RSS File

By Nicholas Chase
2003-12-19
Reader Rating: 4 out of 5
Bookmark Print Version
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.


Article 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


 Rate this article:   Poor          Excellent 


If you found this article interesting, you may want to read these as well:

» Better SOAP Interfaces With Header Elements

» Variable Substitution In XML Documents

» Create JPEGs Automatically With SVG

» Tip: Convert from HTML to XML with HTML Tidy



 
Development Tutorials: CGI & Perl - CSS - HTML - Java - JavaScript - Linux - PHP - XML
More Resources: Web Hosting Articles - Web Development News - PHP Manual