I have one GET Restful service
that return JSON. I have to get Response time of that service.
My requirement is that when i try to get JSON data from that service and if that service take more than 10 seconds then i have to redirect it some another page.
So how can i do this?
My code is given below
import java.net.URL;
import java.net.HttpURLConnection;
URL url = new URL(sURL);
HttpURLConnection req = (HttpURLConnection) url.openConnection();
req.connect();
if (req.getResponseCode() == HttpURLConnection.HTTP_OK) {
System.out.println("ResponseCode = HTTP_OK");
}
I am using Java with Eclipse Mars 1.