title: Java HTTP PUT not sending the data
body: <p>I want to send some data to a server over HTTP PUT (calling a REST web service). Below is the code..</p>
  
  <pre><code>URL urlObj = new URL("http://99.66.66.238:8443/media/service");
            HttpURLConnection conn = (HttpURLConnection) urlObj
                  .openConnection();
          conn.setDoOutput(true);
          conn.setUseCaches(false);
          conn.setRequestMethod("PUT");
          conn.setRequestProperty("accept-charset", "UTF-8");
          conn.setRequestProperty("content-type",
                  "application/x-www-form-urlencoded");
  
          String userPassword = username + ":" + password;
          byte[] authEncBytes = Base64.encodeBase64(userPassword.getBytes());
          String authStringEnc = new String(authEncBytes);
          conn.setRequestProperty("Authorization", "Basic " + authStringEnc);
  
          OutputStreamWriter writer = new OutputStreamWriter(
                  conn.getOutputStream(), "UTF-8");
          writer.write(requestXML);
          conn.getOutputStream().flush();
  </code></pre>
  
  <p>But on the other side, they do not get the data. They only see..</p>
  
  <pre><code>PUT /media/service HTTP/1.1
  accept-charset: UTF-8
  content-type: application/x-www-form-urlencoded
  Authorization: Basic cm10dGVzdDpwYXNzd29yZA=3D=3D
  Cache-Control: no-cache
  Pragma: no-cache
  User-Agent: Java/1.6.0_13
  Accept: text/html, image/gif, image/jpeg, *; q=3D.2, */*; q=3D.2
  Connection: keep-alive
  Content-Length: 0 
  </code></pre>
  
  <p>Notice how the Content-Length is 0. Can you please tell me why the data is not going through? Is there anyway I can see exactly what I am sending?</p>
  
  <p>Thanks.</p>