title: Basic Http server PUT request in java
body: <p>I'm currently learning on how to use HTTP request with java I've done a GET request that works properly :</p>
  
  <pre><code>static class ThermostatHandler implements HttpHandler {
  
      @Override
      public void handle(HttpExchange he) throws IOException {
          String requestMethod = he.getRequestMethod();
          if (requestMethod.equalsIgnoreCase("GET")) {
              String response = Smart.thermostatsGlobal;
              addResponseHeader(he);
              he.sendResponseHeaders(200, response.length());
              try (OutputStream os = he.getResponseBody()) {
                  os.write(response.getBytes());
              } 
          }             
      }
  }
  </code></pre>
  
  <p>Now im trying to do a PUT request but can't find any help using these imports :</p>
  
  <pre><code>import com.sun.net.httpserver.HttpExchange;
  import com.sun.net.httpserver.HttpHandler;
  import com.sun.net.httpserver.HttpServer;
  </code></pre>
  
  <p>I cannot use different imports I can add some tho using the <em>.httpserver.</em></p>
  
  <p>Any help on how to send data lets say to Smart.thermostatsGlobal but with a PUT it could be any type of data but I would prefer a string</p>
  
  <p>the route is localhost:8000/thermostats</p>
  
  <p>Thank you</p>
  
  <p>EDIT: </p>
  
  <p>Its for learning purposes I need to use those sun packages sadly and im on java 8</p>