HttpURLConnection GetResponseMessage() Example
Gets the HTTP response message, if any, returned along with the response code from a server.
HttpURLConnectionclass GetResponseMessage() method example. This example shows you how to use GetResponseMessage() method.This method Gets the HTTP response message, if any, returned along with the response code from a server.
Here is the code:-
/*
* @Program that Gets the HTTP response message,returned along with the response
code from a server.
* GetResponseMessage.java
* Author:-RoseIndia Team
* Date:-25-Jun-2008
*/
import java.net.*;
public class GetResponseMessage {
public static void main(String[] args) throws Exception {
URL url = new URL("http://192.168.10.211:8080");
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
String s=connection.getResponseMessage();
System.out.println("Response message returned is : "+s);
}
} |
Output of the program:-
| Response message returned is : OK |
|