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

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

RSS without limits: JERSS

Thousands of downloads for RSSApplet show the popularity of displaying RSS news headlines on top notch Web sites. For all its simplicity, the limitations of such an applet solution can only be overcome with a server-side approach.

Such a server-side solution is JERSS, a Java servlet for fetching RSS files and handing them over to the Web browser in the form of JavaScript data structures. JERSS is based on the code of RSSApplet.

Applet limitations

The security model of Java applets allow network connections only back to the host from where the applet was loaded. While this is a very useful method for preventing applets from bombarding foreign hosts with unwanted messages, it also prevents the RSSApplet from benevolently retrieving RSS newsfeeds from other servers.

Therefore the only way of displaying RSS headlines from a different host is to get the applet installed on that server first and then include the applet from there in one's own Web page using the archive and codebase directives:

<APPLET
  ARCHIVE  = "https://foreign.host.net/rssApplet.jar"
  CODEBASE = "https://foreign.host.net/"
  CODE     = "com.exploringxml.rss.applet.RSSViewerApplet.class"
  NAME     = "rssApplet"
  WIDTH    = 400
  HEIGHT   = 300
>
<PARAM NAME = "src" VALUE = "https://foreign.host.net/news.rss">
</APPLET>

Integrating the above HTML snippet on myhost.mynet.net allows for embedding RSS news from the foreign host, given the applet is installed at the given URL.

Contrasting the servlet solution

Servlets have no access restrictions for retrieving other URLs, the java.net.URLConnection class makes it easy to download content from other Web sites. Piping this content such as remote RSS files through an RSS / XML parser and forwarding it to the requesting browser neatly circumvents that restriction.

Installing the servlet

Prerequisite for installing the servlet is a servlet engine, such as Apache Tomcat, Resin or many commercial Java application servers. Installing a servlet is engine-specific, but usually all that is required is to include the downloaded JERSS.zip in the servlet engine's CLASSPATH and map a URI path onto the main servlet class RSSViewerServlet.class.

You also need to extract the included rss.js and place it somewhere under your Web server's root directory. This file contains the JavaScript code that you need to include in the Web pages where you want the RSS news to be displayed.

Using the servlet.

Produced by Michael Claßen

Created: Sep 16, 2001
Revised: Sep 16, 2001