• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Problem grabbing RSS from a website and displaying it from servlet

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
The human mind is a dangerous plaything. This tiny ad is pretty safe:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic