hello
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:
EmployeeForm empForm=(EmployeeForm)form;
String name=empForm.getName();
byte[] temp=name.getBytes("ISO8859_1");
name=new String(temp);
empForm.setName(name);
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?
thank you
-
question about chinese charactor in struts (2 messages)
- Posted by: zhebin cong
- Posted on: May 25 2002 06:22 EDT
Threaded Messages (2)
- question about chinese charactor in struts by Abhijit Gaikwad on May 27 2002 08:49 EDT
- question about chinese charactor in struts by Lothar Hegebart on June 07 2002 18:11 EDT
-
question about chinese charactor in struts[ Go to top ]
- Posted by: Abhijit Gaikwad
- Posted on: May 27 2002 08:49 EDT
- in response to zhebin cong
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
Cheers,
Abhijit
-
question about chinese charactor in struts[ Go to top ]
- Posted by: Lothar Hegebart
- Posted on: June 07 2002 18:11 EDT
- in response to zhebin cong
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 ;-)