I am finding a issue where the data is encoded properly in the controller and compiled jsp, but is not displaying properly within an alert statement (or on the page). Please see the following configurations.
- tomcat server property
-Dfile.encoding=UTF8
- java controller - hard coded value
renderRequest.setAttribute("general", "¯_(ツ)_/¯ ¯_(ツ)_/¯");
- first line in jsp
<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
- jsp scriptlet to display session attribute
<%
String general = (String)request.getAttribute("general");
System.out.println("#### general is: " + general);
%>
#### general is: ¯_(ツ)_/¯ ¯_(ツ)_/¯
- html in jsp
<p>¯_(ツ)_/¯ ¯_(ツ)_/¯</p>
<pre>'<%= request.getAttribute("general") %>'</pre>
- compiled jsp snippet showing encoded chars
out.write("\t\t<p>¯_(ツ)_/¯ ¯_(ツ)_/¯</p>\r\n");
- all display
¯_(ツ)_/¯ ¯_(ツ)_/¯
- web.xml configuration
<filter>
<filter-name>setCharacterEncodingFilter</filter-name>
<filter-class>org.apache.catalina.filters.SetCharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
<async-supported>true</async-supported>
</filter>
- server.xml configuration
<Connector URIEncoding="UTF-8" connectionTimeout="20000" port="7070" protocol="HTTP/1.1" redirectPort="8443"/>
What sort of simple configuration am I missing here?
<meta charset="utf-8"/>in your html<head>and is your JSP really saved as UTF-8 (text encoding)?