The page stops rendering and throws XML parsing error such as "semi colon expected somewhere in my javascript" or "processing instruction not found" etc etc.
That will happen if you declare XHTML as XML instead of "HTML with XML syntax". Indeed get rid of that XML declaration. If you can, I'd go a step further and just use HTML as real HTML, i.e. use <!doctype html>
or any other HTML strict
doctype. Also see http://hsivonen.iki.fi/doctype/.
<% request.setCharacterEncoding("UTF-8"); %>
First detail is that the request.setCharacterEncoding("UTF-8")
is way superfluous. At this stage it's already too late to set that. Second detail is that you're using scriptlets for that. I recommend not to do so. Use taglibs/EL where appropriate. If that's not possible, then the code logic actually belongs in a Java class, either directly or indirectly in a Servlet or Filter class.
Removing "charset=utf-8" from response.setContentType makes the page render. The only problem is that → shows up as a questin mark "?"
The response.setContentType(..)
is superfluous if you already set it as a <meta>
tag in the HTML <head>
which is imho much cleaner.
Finally you also need to set the response character encoding (that's different from setting the content type!) as follows:
<%@ page pageEncoding="UTF-8" %>
This by the way also implicitly creates a <meta>
tag for the content-type
. More background information and hints can be found here.
Hope this helps.