Programming Tips - Java: Get the status from an HttpResponse

Date: 2013dec18 Language: Java Q. Java: Get the status from an HttpResponse A.
HttpResponse response = client.execute(request); StatusLine sl = response.getStatusLine(); int statusCode = sl.getStatusCode(); // statusCode will be the familiar HTTP codes like 200 for success // and 404 for page not found. // Do NOT do this: if (statusCode != 200) { // This is bad because there are other ways a page can succeed. return false; }