Bugzilla-Query using Java - Getting HTML instead of XML

74 views Asked by At

When I type this following URL into my browser, Bugzilla answers with XML:

http://bugzilla.mycompany.local/buglist.cgi?ctype=rdf&bug_status=CONFIRMED&product=MyProduct

I want to process this XML in a Java program. But when I use the exact same URL in my Java program, Bugzilla answers with HTML instead of XML.

This is my program:

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;

public class Test {
    public static void main(String[] args)
            throws IOException {
        URL url = new URL("http://bugzilla.mycompany.local/buglist.cgi?ctype=rdf&bug_status=CONFIRMED&product=MyProduct");
        URLConnection connection = url.openConnection();
        final StringBuilder response = new StringBuilder(1024);
        try(InputStreamReader isr = new InputStreamReader(connection.getInputStream())) {
            try(BufferedReader reader = new BufferedReader(isr)) {
                String inputLine = null;
                while((inputLine = reader.readLine()) != null) {
                    response.append(inputLine);
                    response.append('\n');
                }
            }
        }
        System.out.println(response);
    }
}

What am I doing wrong?

1

There are 1 answers

0
user2995410 On BEST ANSWER

The resulting HTML is not the result of the query. It's Bugzillas log-in form. Duh!