ATG RSS Generator Droplet

Home/Java/ATG/ATG RSS Generator Droplet

I sat down a few hours ago to start a droplet which would generate an RSS feed based on data in an ATG Repository. Surprisingly, I think I’m done.

Basically what it is is a droplet, which you put on an otherwise empty JSP page (it’s important that there is no whitespace on the JSP as well). You configure the droplet via it’s .properties file to point to a Repository, and you give it an item descriptor, which will be the primary item to use for the data in the feed. You then configure a bunch of mostly optional data points for the channel data of the RSS feed (this includes things like the main site link, the RSS feed title and description, and optional elements like author, copyright information, etc…

Then you provide the property names (and nested “.” driven properties are okay here) for the various elements of the RSS Item like title, link, description, publish date, etc… Currently it sorts based on the publish date property, to provide items in newest-to-oldest order. I may support a separate sort property later on if people want one.

Since many repository items may not have a usable link property, you can pass in a itemLink property value with an embedded property (also supporting nested properties, and supporting the special repositoryId). For instance you can do this:

itemLink=/catalog/product.jsp?productId=#{repositoryId}

or even something like:

itemLink=http://#{author.homepageURL}?referrer=mySite

The JSP page, when hit, generates a nice RSS 2.0 compliant feed based on the data in the Repository.

You can also include the following in your <head> element of your site’s main page to get the nice automatic feed discovery in many browsers:

<link href="http://mysite.com/rss.jsp" rel="alternate" type="application/rss+xml" title="RSS" />

You can download the entire package here. This includes the source, a heavily commented properties file, a jsp file, and a jar file to load into your classpath.

Some examples where you might want to use this: Blog, Newsletter, any site with updated content, a commerce site’s catalog, discussion forums, etc…..

Enjoy!

By | 2017-05-18T15:19:02+00:00 August 13th, 2007|ATG, Java|6 Comments

About the Author:

6 Comments

  1. Matt Sidesinger March 24, 2008 at 1:39 pm - Reply

    FYI, You could have used the StrSubstitutor in the code that resolves variables in the itemLink property.

    http://commons.apache.org/lang/api-release/org/apache/commons/lang/text/StrSubstitutor.html

  2. Devon March 24, 2008 at 2:00 pm - Reply

    Good call!

  3. Doug Henderson April 16, 2008 at 8:31 am - Reply

    Hey Devon,
    Thanks for sharing this code with the world. We just recently decided to use RSS feeds
    for our press releases. So I pointed the repository to our PR rep, and used the title and
    publishDate as the items to expose and sort by. But I am having trouble with the end
    game here. That is, using the above “link href” the Firefox 2 and Sage RSS readers don’t
    seem to want to recognize the channel/feed as RSS and instead spew the rendered
    contents on the jsp page, rather than have them be discoverable feeds. I am using your
    rss.jsp page and the droplet is communicating fine with results. Did you ever have such
    a problem and perhaps could shed light on what I might be doing wrong here?
    Thanks, Doug

  4. Devon April 17, 2008 at 9:26 pm - Reply

    Hmm. Honestly I only tested it using the Safari built-in RSS reader, so it’s possible that the other readers need a special content type header or something? I don’t have a good answer for you, but I’m happy to work with you to figure it out. Do you have any sample code you can send me or a world facing URL? Feel free to e-mail me: devon@digitalsanctuary.com

  5. Devon April 23, 2008 at 2:48 pm - Reply

    For all of you who are following along at home: the moral of this story is to not reformat the JSP or the added whitespace breaks picky RSS readers.

    I’ve also identified a few other areas where my output isn’t 100% in line with the strict spec, which I will work on fixing when I get back from France. However, it seems to work with most readers as is, so don’t hesitate to use it.

  6. […] me some code updates I have released a new version of the RSS Feed Droplet (first mentioned in this post) which supports configurable character encodings. This can be very useful if you have “interesting” […]

Leave A Comment