Java post request interface

public static JSONObject doPost(String url,JSONObject json){ DefaultHttpClient client = new DefaultHttpClient(); HttpPost post = new HttpPost(url); JSONObject response = null; Try { StringEntity s = new StringEntity(json.toString()); s.setContentEncoding("UTF-8"); s.setContentType("application/json");//Send json data needs to set contentType post.setEntity(s); HttpResponse res = client.execute(post); If(res.getStatusLine().getStatusCode() == HttpStatus.SC_OK){ HttpEntity entity = res.getEntity(); String result = EntityUtils.toString(res.getEntity());// Returns the json format: Response = JSONObject.fromObject(result); } } catch (Exception e) { Throw new RuntimeException(e); } Return response; }