title: Java setting cookies through stream
body: <p>I am writing a webserver, and I need to set a cookie on the client's web browser.
  I get a OutputStream through Socket.getOutputStream(), but I cannot find a way to send a header with it. I tried sending javascript code to set the cookie on the client side, but the cookies set that way are not being sent back to the server.
  How can I set a cookie through the header/other way.</p>