title: can not send response message from httpserver created using java
body: <p>I am creating httpserver in my application, using:</p>
  
  <pre><code>HttpServer server = HttpServer.create(new InetSocketAddress(8000), 0);
  </code></pre>
  
  <p>This server first send response message using</p>
  
  <pre><code>OutputStream os = httpEx.getResponseBody();
  os.write(("your request is being handled, please wait").getBytes());
  </code></pre>
  
  <p>and then opens one jFilechooser. also if anything goes wrong it will throw error using</p>
  
  <pre><code>os.write(("Failed to handle your request").getBytes());
  </code></pre>
  
  <p>When my application runs on user's machine, it creates httpserver properly, as I could find through logs but when user sends any request to this server, nothing happens. It displays blank page. But when I remove all <code>os.write</code> lines it works fine and displays the filechooser pop-up. I am not aware what is going wrong. Please help me on this.
  I have tried these approaches:</p>
  
  <pre><code>try {           
              os.write(("Your request is being handled, please wait").getBytes());
              os.close();
              //code to open Jfilechooser pop-up
  
          } catch (Exception e) {
              os.write(("Failed to handle the request because"+e.getMessage()).getBytes());
              os.close();}
  </code></pre>
  
  <p>and</p>
  
  <pre><code>    try {           
                  os.write(("Your request is being handled, please wait").getBytes());
  
                  //code to open Jfilechooser pop-up
  
              } catch (Exception e) {
                  os.write(("Failed to handle the request because"+e.getMessage()).getBytes());
                  }
  
  os.close();
  </code></pre>