A simple UTF-8 problem with a new Tomcat running in Eclipse:
My index.html
in UTF-8 works perfectly, and Eclipse can display the UTF characters. But wrapping it in this index.jsp
is not working:
<?xml version="1.0" encoding="UTF-8"?><%@ page contentType="text/html; charset=UTF-8" %><% response.setHeader("Cross-Origin-Embedder-Policy", "require-corp"); response.setHeader("Cross-Origin-Opener-Policy", "same-origin"); response.setCharacterEncoding("utf-8");%><%@ include file="index.html" %>
Another JSP page without <%@ include ...%>
has UTF-8 in the html body, and works perfectly. (It is actually on a second Tomcat instance, and managed to send "👁↑" across a websocket to be displayed correctly on the index.jsp via JavaScript. Only the HTML-embedded UTF in the static index.html does not render when wrapped into the index.jsp as above.)
Why? (If you don't know an immediate short answer, don't bother. This is too ridiculous.)
I have tried org.apache.catalina.filters.SetCharacterEncodingFilter
in web.xml
, and set URIEncoding="UTF-8"
in the connector tag in server.xml
. No effect. It gets worse when adding a <jsp-config><jsp-property-group><page-encoding>UTF-8</page-encoding>...
to web.xml
: Server then complains about my Javascript files (whose UTF-8 works perfectly in static index.html)