Q:

Server Sent Event HTML5 error(the resource from this url is not text)

I wrote this Servlet:
 protected void doGet(HttpServletRequest request, HttpServletResponse response) throws 
    ServletException, IOException {
    response.setContentType("text/event-stream;charset=UTF-8");
    response.setHeader("Cache-Control","no-cache");

    PrintWriter printWriter=response.getWriter();
    printWriter.write("Hello!");
}

and also this java script in index.jsp:
<script>
    var resource = new EventSource("/servlet");
    resource.onmessage = function (e) {
        document.getElementById("container").innerHTML = e.data;
    }
</script>

in order to create demo on server-sent events in html5. I inspected the jsp page in firefox and I got this error: the resource from this url is not text and nothing shows up. by the way request status is 200, OK. What is wrong with that?  

A:

Try to change the response header
response.setContentType("text/event-stream");  

