title: how to implement server-sent-events in JEE6
body: <p>In PHP it really simple:
  I just added this to "b.php":</p>
  
  <pre><code>header('Content-Type: text/event-stream');
  echo "data: Hi\n\n";
  flush();
  </code></pre>
  
  <p>and this to "a.html":</p>
  
  <pre><code>var source = new EventSource("b.php");
  source.onmessage = function (event) {
  document.body.innerHTML += event.data + "&lt;br&gt;";
  </code></pre>
  
  <p>I just need to go a.html and it's works! </p>
  
  <p>But in java I've tried to create servlet and in doGet I added this code:  </p>
  
  <pre><code>response.setContentType("text/event-stream");
  
  PrintWriter out = response.getWriter();  
  out.println("data: Hi\n\n") ;
  out.flush();
  </code></pre>
  
  <p>And when I go to a.html (same as above) I can see that doGet is indeed invoked (in debugger) but the "onmessage" event is never happened.</p>
  
  <p>How to start with SSE in JEE6? somebody can write me an example that works?</p>
  
  <p>Thanks.</p>