rss| Tutorial RSS (Really Simple Syndication, a really easy chain) is a WEB content chain format. RSS becomes a standard format for WEB-linked news content. As part of a recent contract with Sun Microsystems, I am responsible for developing a "JSP tag library" that anyone who knows RSS, JavaServer Pages, and HTML can use. Taglib is primarily intended for non-technical editors of WEB sites that use RSS to collect news content. My goal is to develop a JSP tag library that will simplify the use of RSS content (versions 0.91, 0.92, and 2.0) in a Web page.
RSS Utilities Package is the result of this project. It includes a set of custom JSP tags that make up the RSS Utilities Tag library and the flexible RSS parser. This document describes how to use the parser and RSS Utilities Package to provide libraries. Click here to download the first version. The zip file contains a jar file Rssutils.jar (which contains the classes needed to use the tool) and a TLD file that defines a JSP custom label that extracts information from an RSS document.
Install Taglib
Although it is easy to use a tag library, it is required at installation time to understand how the WEB server works and how to configure it. The first step is to download and unpack the package. Once the zip file has been uncompressed, place a copy of Rssutils.jar and Rsstaglib.tld in the/web-inf/lib directory of the WEB application. Add the following taglib definition to the/web-inf/web.xml file for the WEB application:
<taglib> <taglib-uri>/WEB-INF/rssutils.tld</taglib-uri> <taglib-location>/WEB-INF/rssutils.tld</taglib-location> </taglib> Using Taglib
Once the taglib has been installed in the WEB application, follow these steps to use taglib in the JSP page. First, add the following line to the top of the JSP page:
<%@ taglib uri="/WEB-INF/rssutils.tld" prefix="rss" %> Second, use the Feed tab to add the RSS feed to the JSP page, as shown in the following example:
<rss:feed url="http://servlet.java.sun.com/syndication/rss_java_highlights-10.xml" feedId="javaSunCom"/> The URL property of the feed label must be included in the URL of the RSS document. The Feedid property of the Feed tab is arbitrary and can be set to any value. However, we recommend that the attribute be intuitive when identifying the RSS feed. If your application is behind a firewall, you can set agent properties by using the Feed label Agent property named ProxyAddress and ProxyPort. If you do not know the proxy server address proxy port, contact your network administrator. Here is an example:
<rss:feed url="http://servlet.java.sun.com/syndication/rss_java_highlights-10.xml" feedId="example1" proxyAddress="129.149.246.4" proxyPort="8080"/> Once you add one or more RSS feeds to a page, you should be able to use the remaining set of tags to extract almost any information from the feed. Here is an example of how to extract the title of the RSS feed channel added above:
In a way, the parser is a by-product of the project. Although the parser is developed with a tag library, it is entirely self-contained and can be used in Java applications. However, to do this, it is clear that you need at least an understanding of how to write basic Java code. (If you know how to write Hello world in the Java language, there's no problem.) )
First download and unpack the package. Once you have added Rssutils.jar to your classpath, use Rssparserfactory to create an instance of the Rssparser interface:
RssParser parser = RssParserFactory.createDefault(); Rss rss = parser.parse(new URL("http://mydomain.com/document.rss")); The parser-generated RSS object is the Java object representation of the RSS document that is located in the provided URL. Use the methods provided by the RSS object to get handles to other RSS objects, such as channels and Items. Rssparser can also parse File objects and InputStream objects.
Conclusion
RSS provides an easy way to add and maintain news and other content from all Web sites on your Web site. Even if RSS is a simple XML format, parsing and extracting data from an XML document anywhere else on the WEB can be tricky--or at least tedious--if you have to do it over and over again. RSS Utilities Package uses Custom Tag and XML parsing technology to make the real Simple syndication format truly the same as its name.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.