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)
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.
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
Joined: Mar 22, 2005
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.
Joined: Apr 30, 2011
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
subject: Problem grabbing RSS from a website and displaying it from servlet