Friday, June 14, 2013

EventSource's response has a charset ("iso-8859-1") that is not UTF-8. Aborting the connection Error

SERVER SENT EVENTS, HTML5 AND TOMCAT 7

If you test, you can understand that there is no problem while running the project with Tomcat 6.

Yes, the problem is with Tomcat 7. It supports charset : iso-8859-1 by default.
So, we need to fix this problem with describing that we are using character encoding(charset)  UTF-8.

Change the responce.setContentType as follows:

response.setContentType("text/event-stream, charset=UTF-8");


Thats it.

3 comments: