RSS without limits: JERSS (2/2) - exploring XML | WebReference

RSS without limits: JERSS (2/2) - exploring XML

RSS without limits: JERSS

Using the servlet

The JERSS servlet takes two parameters, and returns JavaScript objects populated with information about the news headlines. The Web author can then use JavaScript and these populated objects to generate HTML that presents the headlines in whatever manner the author sees fit. This way the author has 100% control over the design of the presentation.

If you use the JERSS servlet to include at least one newsfeed in your Web page, you must include the following script tag in the HEAD of your HTML document:

<SCRIPT TYPE="text/javascript" LANGUAGE="JavaScript" SRC="/path/to/rss.js">
</SCRIPT>

To add a newsfeed to your Web page, include the following tag in the HEAD of your HTML document (you should include one tag per channel you want to include - if you have three channels, you'll have three of these tags):

<SCRIPT TYPE="text/javascript" LANGUAGE="JavaScript"
SRC="/path/to/RSSViewerServlet?url=[RSS]&prefix=[x]">
</SCRIPT>

Replace [RSS] with the URL of the RSS newsfeed you want to include on your Web page. For example, if you want to include the latest stories from WebReference, you'd use the URL http://www.webreference.com/webreference.rss. Replace [x] with a prefix you'd like to use to uniquely identify the variables associated with this particular newsfeed. This is optional and is useful if you want to include multiple newsfeeds on one Web page.

To create HTML out of the JavaScript generated by the JERSS servlet, you'll need to write some JavaScript of your own. Exactly how you do this is up to you, because it will be unique to the design of your Website. However, there are some things to keep in mind:

Here's an example of some very simple JavaScript to produce some very simple HTML to display news headlines (it assumes the prefix "top" was used when including the channel):

<script>
document.write( "<h2><a href='"+topchannel.link+"'>"+topchannel.title+"</a></h2><h3>"+
topchannel.description+"</h3>");
for (i=0; i<topNumberOfItems; i++){
   document.write("<b><a href='"+topitems[i].link+"'>"+topitems[i].title+"</a></b><br>"+
topitems[i].description+"<br>");
}
</script>

Conclusion

The servlet solution elegantly works around the access restrictions that are placed on applets and therefore the limits inherited by RSSApplet. The RSS information is handed to the browser as JavaScript data that can be inserted into the HTML page. This way integrating the RSS news feed into one's own site is seamlessly possible.

Produced by Michael Claßen

URL: http://www.webreference.com/xml/column39/2.html
Created: Sep 16, 2001
Revised: Sep 16, 2001