Java Mailing List Archive

Home » Home (12/2007) » Struts Users »

Tomcat/Struts Unicode Encoding/Decoding problems

Theodosios Paschalidis



Hi all,

I am trying to setup a database driven web site that displays unicode characters. I have spent much time on this but my attempts have been unsuccessful.

I have tested my JDBC business logic with the database and works fine but when I use my application to perform a search it fails to find anything, ie it does not correctly retrieve international characters. (It must be a struts/server issue) When I printout the string used, it appears mangled both in the Tomcat console and my JSP.
If I display Unicode characters retrieved from the database they again appear mangled. (Mind you that my UTF-8 encoded Message bundle displays fine on the same page!)

Here is what I have done.

JSP setup

<%@(protected)" %>

<html:form action="/DoSearch" focus="title" method="post" target="content" enctype="text/plain;charset=UTF-8" >

to change the server's decoding I used
<% request.setCharacterEncoding("UTF-8"); %>
before retrieving my form data

 out.print("RESPONSE character encoding=" +response.getCharacterEncoding()+" " );
 out.print("REQUEST character encoding=" +request.getCharacterEncoding()+" " );
 out.println("JVM encoding " +System.getProperty("file.encoding")+" ");

Reveals "UTF-8" encoding for server response/request and "Cp1253" (standard Greek windows code page) for the JVM. (could this be the problem? Is there a way to change this?)

Tomcat Setup
I have added the following in startup.bat



Software components.
- OS: Microsoft Windows XP Pro
- Database: mysql-4.1.1
- JDBC: mysql-connector-java-3.1.0
- Web Server: jakarta-tomcat-4.1.24
- Framework: struts 1.1
- Development Tool: NetBeans 3.5

Should I be configuring something in struts instead? Maybe an encoding parameter in either web.xml or struts-html?

I am out of ideas so any help will be greatly appreciated.

Thank you for your time,
©2008 - Jax Systems, LLC, U.S.A.