Q: RSS Parser returns 403 I'm new to Java and we were given an assignment about XML Parsing. We have done DOM and now we are on SAX. That's why I'm using SAX Parser for parsing an rss feed. Its already working on files but when I try to parse an online rss feed, it returns an Error 403. I haven't tried parsing the same site on DOM because my laptop is so slow it takes me 5 minutes just to open a file.
Thanks for the help.
public class NewsHandler extends DefaultHandler {
    private String url = "http://tomasinoweb.org/feed/rss";
    private boolean inDescription = false;

    private String[] descs = new String[11];

    int i = 0;

        public void processFeed() {
             try {
             SAXParserFactory factory = 
             SAXParserFactory.newInstance();
             SAXParser parser = factory.newSAXParser();
             XMLReader reader = parser.getXMLReader();
             reader.setContentHandler(this);
             InputStream inputStream = new URL(url).openStream(); 
             reader.parse(new InputSource(inputStream));

             } catch (Exception e) { e.printStackTrace(); }
        }
        public void startElement(String uri, String localName, String qName,
             Attributes attributes) throws SAXException {
            if(qName.equals("description")) inDescription = true;

        }

        public void characters(char ch[], int start, int length) {
             String chars = new String(ch).substring(start, start + length);
             if(inDescription) descs[i] = chars;

        }

        public void endElement(String uri, String localName, String qName) throws SAXException {
            if(qName.equals("description")) { 
                          inDescription = false;
                          i++; 
                    }
        }

        public String getDesc(int index) { return descs[index]; }

        public static void main(String[] args) {
            NewsHandler nh = new NewsHandler();
            nh.processFeed();

            for(int i=0; i<10; i++) {
                System.out.println(nh.getDesc(i));
            }

        }
}


A: Solution:
Instead of using String url = "url", I used URL url = new URL("url") and URLConnection con = url.openConnection() and then con.addRequestProperty("user-agent", user-agent string);
