Hello,

I am very new to java and I am trying to create an rss feed on a live website. Using netbeans, I have created a source package called RSSParserTest.java that a jsp uses called redesignrss.jsp. This jsp works perfectly in netbeans, it opens a browser window and shows up the 5 most recent feeds from the CNN rss feed.
I want to now want this rss program to work on one of my websites. Iím really lot about how to go about this. Any help would be appreciated.


RSSParserTest.java

package rss;

import com.sun.cnpi.rss.elements.Category;
import com.sun.cnpi.rss.elements.Item;
import com.sun.cnpi.rss.elements.Rss;
import com.sun.cnpi.rss.parser.RssParser;
import com.sun.cnpi.rss.parser.RssParserFactory;
import java.net.URL;
import java.util.Collection;
import java.util.Iterator;

import java.util.Vector;

public class RSSParserTest {
private Vector titleVector = new Vector();
private Vector linkVector = new Vector();
private Vector descVector = new Vector();

public void readRSSDocument(String url) throws Exception{
RssParser parser = RssParserFactory.createDefault();
Rss rss = parser.parse(new URL(url));
//Get all XML elements in the feed
Collection items = rss.getChannel().getItems();
if(items != null && !items.isEmpty())
{
//Iterate over our main elements. Should have one for each article
int limit =0;
for(Iterator i = items.iterator(); i.hasNext() && limit<5;System.out.println())
{
Item item = (Item)i.next();
limit++;
getTitleVector().add(item.getTitle());
getLinkVector().add(item.getLink());
getDescVector().add(item.getDescription());
System.out.println("Title: " + item.getTitle());
System.out.println("Link: " + item.getLink());
System.out.println("Description: " + item.getDescription());
}
}
//Iterate over categories if we are provided with any
Collection categories = rss.getChannel().getCategories();
if(categories != null && !categories.isEmpty())
{
Category cat;
for(Iterator i = categories.iterator();
i.hasNext();
System.out.println("Category Domain: " + cat.getDomain()))
{
cat = (Category)i.next();
System.out.println("Category: " + cat);
}

}
}
public static void main(String args[])
{
RSSParserTest rsstest = new RSSParserTest();
try{
rsstest.readRSSDocument(".....rss link....");
}catch(Exception ex){ex.printStackTrace();}
}

public Vector getTitleVector() {
return titleVector;
}

public void setTitleVector(Vector titleVector) {
this.titleVector = titleVector;
}

public Vector getLinkVector() {
return linkVector;
}

public void setLinkVector(Vector linkVector) {
this.linkVector = linkVector;
}

public Vector getDescVector() {
return descVector;
}

public void setDescVector(Vector descVector) {
this.descVector = descVector;
}
// }
}




How do I get this to work and display in a html file?