how to implement server-sent-events in JEE6
问题 In PHP it really simple: I just added this to "b.php": header('Content-Type: text/event-stream'); echo "data: Hi\n\n"; flush(); and this to "a.html": var source = new EventSource("b.php"); source.onmessage = function (event) { document.body.innerHTML += event.data + "<br>"; I just need to go a.html and it's works! But in java I've tried to create servlet and in doGet I added this code: response.setContentType("text/event-stream"); PrintWriter out = response.getWriter(); out.println("data: Hi