Feed servlet 1.1

    It is a Java servlet lets you request RSS (Atom) feeds from sites and return data in JSON (JSONP) format. So your JavaScript application will be able to proceed obtained feeds for any arbitrary URL.

The idea is very simple. Servlets returns JavaScript code. So adding this JavaScript code dynamically to your page lets you bypass any sandbox restrictions and deal with the remote data sources.

How to use it:

a) copy feedPackage.jar into your WEB-INF/lib directory.

b) define a servlet in your web.xml file. You can define the following optional initial parameters:

timeout - describes a timeout for your request (in milliseconds).
proxyHost - describes proxy settings for your system.
proxyPort - describes proxy settings for your system.


define a mapping:


Servlet accepts the following parameters:

url - URL to be requested
callback - Optional parameter. Describes a name for your JavaScript callback
name - Optional parameter. Describes a user name (for the protected sites)
password - Optional parameter. Describes a password (for the protected sites)

    The following example illustrates the usage. This code requests RSS feeds from our blog http://servletsuite.blogspot.com. JavaScript function f describes our callback.

<script language="JavaScript">

function f(info)
alert("Feeds: "+info.length);
for (var x in info)
alert("Rel: "+info[x].rel);
alert("Title: "+info[x].title);
alert("Type: "+info[x].type);
alert("href: "+info[x].href);

var e = document.createElement("script");
e.src = 'http://your_server/servlet/feed?url=http://servletsuite.blogspot.com&callback=f';


Servlet supports cache so the subsequent requests for the same host will get data from the cache without the getting and parsing the real HTML. If the remote host is not available or feeds are not provided servlet will return an empty array.

For JSP applications you can use Find feed taglib.

    For downloading:  feedPackage.jar   

  © Coldbeans     Comments?

See also JSOS - the largest collection of servlets and filters.

Also in JSOS: