• Post Reply Bookmark Topic Watch Topic
  • New Topic

JSP, Bean and IO Stream  RSS feed

Jamal Romero
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm trying to workout how can I do the following. My question for the moment is what I'm thinking to do is correct, or just a wast of time.
I wanted to convert an RSS news feed(XML format) in to a JSP. I have no problem with that. But the web site that provide the XML file allows me to request the file every 1 hour only. If I referesh my JSP 2 or 3 time the server that provid the XML file generate an error.
I thought of the following technic to avoid the error using JSP, a bean, and an IO stream to save a Date.
I needed a way to save a Date. Using a JSP only I think it's not possible (JSP can't access IO stream).
So I want to use a Bean. Why bean because it's a simple class with a special naming protocol. With the bean I can create the stream to read and write to a file saved on the server. What saved, is the java.util.Date object it's serializable by nature.
With the date saved. I can do the following:
if(RecentDate-SavedDate<1 hour)
read localxmlsaved
read remotenewxml
this just a pseudo language.
Saying all that do you think is a good idea or bad idea. Is there any other way to overcome this constraint.
William Brogden
Author and all-around good cowpoke
Posts: 13078
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When I did this for an example in my XML and eCommerce book, I created a Runnable class that conducted the XML download to a file. That way the timing is easy, you just sleep the Thread between queries.
The JSP then looks for the file and parses it - this is faster than doing a request every time.
Naturally you want the downloading class to be a singleton.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!