1

My Tomcat server.xml and web.xml and jsp page encoding have been set to "UTF-8". When html form post a special characters such as Ď, then java code uses StringEscapeUtils.unescapeHtml4(str) on purposely to save this special character Ď in the db. When I get the value out from DB then do system print out and in jsp tag, both places show the symbol ? (a question mark). With the another post "€ symbol not defined", it solved the jsp rendering problem. But tomcat system output/console still show ? (question mark)

Thank you.

Windy
  • 11
  • 5
  • What database are you persisting the data to and what character set is configured in the database? – M. Rizzo Jan 26 '17 at 20:13
  • It's oracle database. I don't have dba privilege but I can see the Ď showed in db field. Can you also let me know what is the best practice to save the character in DB? I thought saving Ď in db field is easier. But it turns out it seems I have to convert to encoding. – Windy Jan 26 '17 at 20:14

1 Answers1

0

Ok it sounds like you have confirmed the data is being persisted and supported appropriately at the database level. I would now trying to add a servlet filter to have your struts webapp handle all requests and responses as UTF-8 encoded.

Define a character set filter like the following:

<filter-name>Set Character Encoding</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>
</filter>

<!-- Define filter mappings for the defined filters -->
<filter-mapping>
    <filter-name>Set Character Encoding</filter-name>
    <servlet-name>action</servlet-name>
</filter-mapping>
M. Rizzo
  • 1,611
  • 12
  • 24
  • I have this setting already in my web.xml SetCharacterEncoding /* but I replaced with the "action" value. It is still not working. . Pleas advise. thanks – Windy Jan 26 '17 at 21:05
  • Yes. That's what I have in web.xml. But jsp still render ? and system output still show ? . – Windy Jan 26 '17 at 21:27