In your code use the method below after changing your code as follow:
From
System.out.println(uc.getResponseMessage());
To
System.out.println(doHttpUrlConnectionAction(uc));
private String doHttpUrlConnectionAction(HttpURLConnection connection)
throws Exception
{
BufferedReader reader = null;
StringBuilder stringBuilder;
try
{
connection.connect();
reader = new BufferedReader(new
InputStreamReader(connection.getInputStream()));
stringBuilder = new StringBuilder();
String line = null;
while ((line = reader.readLine()) != null)
{
stringBuilder.append(line + "\n");
}
return stringBuilder.toString();
}
catch (Exception e)
{
e.printStackTrace();
throw e;
}
finally
{
if (reader != null)
{
try
{
reader.close();
}
catch (IOException ioe)
{
ioe.printStackTrace();
}
}
}
}