Hi All!!
I was trying to get response code and response message from the server by writing this very small code... but I dont know where I'm making mistake because it is giving UnknownHostException.
Though for all other methods it is working fine except
getResponseCode() and getResponseMessage() methods.
Code goes here:
-------------------
import java.net.*;
import java.io.*;
import javax.swing.*;
import java.awt.*;
public class SourceViewer {
public static void main(
String[] args){
try{
URL u = new URL("http://www.amnesty.org/");
HttpURLConnection uc = (HttpURLConnection) u.openConnection();
int code = uc.getResponseCode();
System.out.println("HTTP 1.x"+code);
}
catch(IOException e){
e.printStackTrace();
System.err.println(e);
}
}
}
-------------
Thanks in advance.........
Hemant