Web tier: servlets, JSP, Web frameworks: question about chinese charactor in struts
- Posted by: u u
- Posted on: May 25 2002 06:22 EDT
i use jbuilder6 bind struts to develop the program,in the program,there is a text box,that is used to input the user name,because i want to input chinese charactor to the box,i use following code snippet in the action class to encode the input charactor:
after i click the submit button,the name will display in the next page,when i start the tomcat built in jbuilder6,test the program within the jbuilder6 window,it works well,but at same time,i open a ie explorer,debug it in the ie,the chinese charactor can't display correctly,i am sure the ie encoding setting is correct. who can help me?
Hi zhebin ,
use appropriate char- encoding for chinese .
ISO8859_1 will not work .
check on site "http://java.sun.com/webservices/docs/ea2/tutorial/doc/Encodings.html" for more details
depends on the tomcat version used in jbuilder6.
versions 3.x by default spit out iso8859_1 and due to the servlet spec there is no way to influence that. workaround possibilities for 3.x are (found it on the tomcat mailing list iirc)
- set the defaultEncoding in server.xml to your desired encoding
- or encode all uri's in your response to the form http://localhost:8080/myapp/index.jsp;charset=UTF-8?param=value. then the defaultinterceptor will recognize this, remove it from the string and remember the encoding for the session further on (only for tomcat 3.3.x possible iirc)
your best option is to use tomcat 4.x which implements servlet spec 2.3 where by the use of a filter you have the possibility to influence the used encoding. see SetCharacterEncodingFilter.java which is supplied with tomcat as an example.
regarding internationalization of webapps and the interaction of browser<->server i learned a lot at http://ppewww.ph.gla.ac.uk/%7eflavell/charset/internat.html and http://ourworld.compuserve.com/homepages/PaulGor/ with the conclusion UTF-8 rules ;-)