tags:

views:

64

answers:

2

Hi all

We have a strange problem, of web app on displaying the UTF-8 characters correctly, here are the facts :

  • Tomcat 6.0.20, running on Ubuntu 9.04
  • We have follows advise here Get UTF-8 Working
  • Our Webapp able to display UTF-8 Character correctly

However, whenever our developer redeploy our webapp module, or when we restart the tomcat, all the UTF-8 Character is being display as ????? at our browser..

We have to do a proper restart of Tomcat (wait Tomcat stop completely, and restart tomcat again), although is annoying, it does solve the problem.

Does anyone come across similar problem before, thanks for your advise.

A: 

Thus, the JSP page encoding went mad. If you have followed the article which you found the right way, then this implicitly means that the

<%@page pageEncoding="UTF-8" %>

has broken.

First step would be to verify the concrete JSP file in the deployed folder if it is still there. Next step would be to verify if its compiled .java file in the appserver's work folder contains at least the following line in the beginning of the try block:

response.setContentType("text/html;charset=UTF-8");

Last step would be to verify the obtained response headers. It depends on the webbrowser how you can view them. In a standard Firefox environment you can find it by rightclick page > View Page Info. The Encoding must mention UTF-8. Also in Firefox, in the top menu bar you can check and play somewhat with character encoding by View > Character Encoding.

Once you have gathered all this information, you must be able to nail down the root cause.

Edit: as a side note, Ubuntu ships out of the box with a buggy GNU JDK/JRE. I strongly recommend to get rid of it and install Sun's own JDK/JRE. You never know, I have already seen many other "unexplainable" problems/bugs been solved by replacing the JDK/JRE with a more solid one.

BalusC
A: 

If you're sure the content is UTF-8, this could work. Set this line in the catalina.sh file (for example, just after the huge initial comment, long before exporting them):

export CATALINA_OPTS=”$CATALINA_OPTS -Dfile.encoding=UTF-8″

Also, we don't know if you're using data from a database. Check if you have put it in there properly.

Alfabravo