title: Cannot onmessage with SSE (Java Servlet + ES6 JS)
body: <p>I was trying to make an example of SSE like in this video <a href="https://www.youtube.com/watch?v=rhCKCKD0KnA" rel="nofollow noreferrer">https://www.youtube.com/watch?v=rhCKCKD0KnA</a></p>
  
  <pre><code>    response.setContentType("text/event-stream");
      response.setCharacterEncoding("UTF-8");
  
      PrintWriter printWriter = null;
  
      while(true) {
  
          try {
              double rnd = Math.random() * 10000;
  
              printWriter = response.getWriter();
              printWriter.print("Rnd: " + rnd);
  
              response.flushBuffer();
  
  
              Thread.sleep(5000);
  
          }
          catch(IOException | InterruptedException e) {
              e.printStackTrace();
  
              printWriter.close();
  
              break;
          }
  
  
      }
  </code></pre>
  
  <p>And client side</p>
  
  <pre><code>    window.onload = function () {
  
          startButton.onclick = () =&gt; {
              eventSource = new EventSource('http://localhost:8080/byteslounge-1/sse_test');
  
              eventSource.onopen = () =&gt; {
                  displayTextArea.value += 'connected...' + '\n';
              };
  
              eventSource.onmessage = (message) =&gt; {
                  displayTextArea.value += message.data + '\n\n';
              };
  
              eventSource.onerror = () =&gt; {
                  displayTextArea.value += 'error occured...' + '\n';
              };
  
              startButton.disabled = true;
          };
  
          takeMsg.onclick = () =&gt; {
              eventSource.onmessage = (message) =&gt; {
                  displayTextArea.value += message.data + '\n\n';
              };
          };
  
          stopButton.onclick = () =&gt; {
              eventSource.close();
              startButton.disabled = false;
          };
  
          clearText.onclick = () =&gt; {
              displayTextArea.value = '';
          }
  
      }
  </code></pre>
  
  <p>Connection is ok, but cannot recieve any data in onMessage. No errors/warnings on the server/client. I'm using FF 64 bit last version/JDK 1.8/Payara.</p>