Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem grabbing RSS from a website and displaying it from servlet

 
William Farrugia
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I'm having some problems when trying to grab RSS feed from a website and display it from a servlet. My servlet runs perfectly on my development machine at home, but fails with this error on the server (CentOS)



My code is as follows:


The website I'm trying to access is http://www.timesofmalta.com/rss

At home I'm running Tomcat 6.0 and on the server Tomcat 5.

At first I suspected the problem might be policy related. (Happened to me on a different server in the past) so I tried to grant access



But that just didn't work.

Any help appreciated

William
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't think it's a permission problem - the request clearly goes out, but is considered incorrect by the server (that's what a 400 response means). A "curl http://www.timesofmalta.com/rss" retrieves the feed fine for me, so this is odd.

By the way, the feed is in UTF-8, so unless your platform default encoding is UTF-8 (and it may well not be), new InputStreamReader(u.getInputStream()) will get you into trouble; use new InputStreamReader(u.getInputStream(), "UTF-8") instead.

You could also use the ROME library; it's the standard Java library for dealing with RSS.
 
William Farrugia
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello!

Thanks for your replied. I tried adding UTF-8 but didn't solve the problem. It still works on my platform but it doesn't on the server. However you did put me in the right direction. Convinced the policies were OK, I tried switching off IPTables on the server, and guess what... it worked!

So now I will try and fix the iptables instead.

Thanks a lot for your help

William
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're welcome.

I tried adding UTF-8 but didn't solve the problem.

It wasn't supposed to; that was just an additional problem I noticed with the code that needed to be addressed.
 
William Farrugia
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ulf Dittmer wrote:It wasn't supposed to; that was just an additional problem I noticed with the code that needed to be addressed.


Sorry I misunderstood then

I had some 8080 to port 80 redirections that were mistakenly added to the output chain on IP tables. I commented out



and it works.

Thanks and regards

William
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic