title: Glassfish REST API
body: <p>I plan to implement a java client to deploy and undeploy the application to Glassfish,</p>
  
  <p>Below is the curr command </p>
  
  <pre><code>curl -s -S \
      -H 'Accept: application/json' \
      -H 'X-Requested-By: dummy' \
      -X DELETE http://localhost:4848/management/domain/applications/application/hello
  </code></pre>
  
  <p>And my java code is </p>
  
  <pre><code>URL url = new URL(
                      "http://localhost:4851/");
              HttpURLConnection conn = (HttpURLConnection) url.openConnection();
              conn.setDoOutput(true);
              conn.setRequestMethod("POST");
              conn.setRequestProperty("Content-Type", "application/json");
  
              String input = "{\"DELETE\":\"http://localhost:4851/management/domain/applications/application/hello\"}";
  
  
              OutputStream os = conn.getOutputStream();
              os.write(input.getBytes());
              os.flush();
  
              if (conn.getResponseCode() != HttpURLConnection.HTTP_CREATED) {
                  throw new RuntimeException("Failed : HTTP error code : "
                          + conn.getResponseCode());
              }
  
              BufferedReader br = new BufferedReader(new InputStreamReader(
                      (conn.getInputStream())));
  
              String output;
              System.out.println("Output from Server .... \n");
              while ((output = br.readLine()) != null) {
  
                  System.out.println(output);
              }
  
              conn.disconnect();
  </code></pre>
  
  <p>Unfortunately, I not able to get the expected result.
  Anyone can help to advice?</p>