Working with RSS and Oracle JDeveloper 10.1.3
Now, it's time to build a simple JSP Web application where you can test the new RSS tags that you've added to JDeveloper.
- To start building a new application, click on File->New..->General->Application. Give it a Name such as "FunWithRSS" and a default package prefix ("com.rss"). Also, select "No Template" for the application templates.
- Click OK to generate an empty Application Workspace. A create project dialog then will appear automatically.
- Name the project "web" (because it will be a Web project).
- Next, you'll create a JSP page by choosing File->New..->Web-Tier->JSP->JSP.
- As the wizard invokes, name the new page "hellorss.jsp" (or whatever you prefer) and click Next to proceed in the JSP wizard.
- Before completing the JSP wizard, you'll encounter a step that allows you to specify that you want to use the RSS Tag Library on the page. Shuttle over the "Rss Tag Library..." onto the Selected side. This will pre-insert the RSS JSP taglib directive into your new JSP page.
- You can now Finish to generate your JSP.
- When the JSP appears in the visual editor, type in banner text such as "Fun with RSS" and format it to H2 using the toolbar. You also can drag and drop a CSS file onto the page to beautify it. To drop a CSS file, select the "CSS" palette page and drop one of the CSS items onto the page. It then will automatically appear with the new look and feel.
- Now, you can start working with the new RSS JSP tags. Change the Component Palette page to "Rss Tag Library" (the new Tag library you added) and drag and drop the Feed tag onto the page:
- A dialog will appear, showing the required field FeedId. Set it to "otn_news".
Now, click on the Advanced Properties tab in the same dialog. You'll see Proxy settings and a URL field. This is where you will insert a Web address pointing to a RSS page.
Add the following address to the URL field:
Note: You won't need to set the proxy in JDeveloper if they're already set in the JDeveloper "Web Browser and Proxy" setting in the preferences. However, if you deploy this to another J2EE server, you'll either need to run the server with the Proxy Server setting or just user these tag attributes for proxy settings.
- Click OK to finish the dialog.
In general, you can find many RSS-enabled pages on the Web, such as CNN, OTN.Oracle.com, and Developer.com.
To see the live RSS feed in its native XML format, simply view the link in a browser such as Mozilla's Firefox or Internet Explorer.
This will help you get a better feel for the data that you'll be parsing with JSP tags.
- In case you are wondering how to find RSS feeds, usually an RSS-enabled Web site will have an icon indicating that it supports RSS newsfeeds. You can find the live RSS XML feed from OTN's home page on the navigation bar on the upper right side:
Getting back to the application. After you assign the OTN RSS News URL to the URL attribute of the Feed tag dialog, click OK. This will insert an RSS feed tag onto your page.
Your source for your feed tag should look like this:
<rss:feed feedId="otn_news" url="http://www.oracle.com/technology/syndication/ rss_otn_news.xml"/>
Next, you can add some code to your JSP to display some data extracted from the live feed.
- Back in the visual designer, add a new paragraph by entering <return> and drag and drop the tag ChannelTitle tag from the palette. Assign the feedId to "otn_news" (the name you used for your feed tag). The source of your tag will look like the following:
- At this point, you could run the page and see the title of OTN's news appear, but add more tags to the page to show all the news items. You can copy and paste the following code:
Important: Make sure to paste the code to the source of the JSP instead of the JSP designer. Click on the "Source" tab at the bottom of the JSP visual editor to edit the source.
<p><rss:channelTitle feedId="otn_news"/></p> <p><rss:channelImage feedId="otn_news" asLink="true"/></p> <p><rss:channelLink feedId="otn_news" asLink="true"/></p> <hr/> <rss:forEachItem feedId="otn_news"> <li> <a href="<rss:itemLink feedId="otn_news"/>" > <rss:itemTitle feedId="otn_news"/> </a> <br/> <rss:itemDescription feedId="otn_news"/> </li> </rss:forEachItem>
Save and run the page by right-clicking on your JSP in JDeveloper's file navigator and select Run. Your JSP will have OTN's news items on the page. Cool, huh!?
- Next, you can build content from Developer.com's RSS News Feed from: http://developer.com/icom_includes/feeds/special/dev-5.xml into a JSP page.
Page 2 of 3