question about chinese charactor in struts


Web tier: servlets, JSP, Web frameworks: question about chinese charactor in struts

  1. question about chinese charactor in struts (2 messages)

    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);

    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
  2. Hi zhebin ,

    use appropriate char- encoding for chinese .
    ISO8859_1 will not work .

    check on site "" for more details

  3. 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 which is supplied with tomcat as an example.
    regarding internationalization of webapps and the interaction of browser<->server i learned a lot at and with the conclusion UTF-8 rules ;-)