----- Original Message ---- > From: senderj <send...@hotmail.com> > To: user@struts.apache.org > Sent: Tue, October 6, 2009 3:28:08 AM > Subject: Struts 1: character encoding > > > The components I use NetBean, Glassfish, Struts 1, EJB, Toplink, jdbc, MySQL. > Basically what I want is to extract info from a web site (utf8 encoded > Chinese), store the info in MySQL, retrieve the info and display on my web > site for user to update/change it. But I got problem on the character > encoding. Here is briefly my logic and coding: > > (1) extract from a web page which uses UTF-8 encoded, my coding in an EJB > run on glassfish: > char c = (char) myInputStream.read(); > Listtoken; > token.add((byte) c); > byte[] ba = new byte[token.size()]; > for (int i=0; i > ba[i] = token.get(i); > } > String s = new String(ba, "UTF-8"); > > I know it can be simpler, but it's a copy of others coding + my > amendment. But it works. > > (2) String s above is stored onto MySQL via toplink, jdbc. Table is DEFAULT > CHARSET=utf8. The jdbc URL is > jdbc:mysql://mysys:3306/testing&useUnicode=true&characterEncoding=utf-8. > > (3) Retrieve by Struts Action via EJB. Both EJB and Action does not have > change of string encoding. The Action put the Chinese string into a > DynaForm, then to JSP. JSP has <%...@page contentType="text/html" > pageEncoding="UTF-8"%> and it generates an html input form. > > (4) However, the Chinese characters were NOT displayed properly in the html > form on IE. > > (5) Anyway, in the html form, I override the incorrect Chinese character by > a writing pad with the correct characters (equivalent to unicode "9326 > 6c5f") and submit. Again, no re-encoding in the Action that process the > update. The Action calls an EJB to update the database with the input data. > But I found that the database was updated with ascii string > "錦江" (exactly this string, not its equivalent > encoded). > > I feel somehow there is/are encoding changes done by the software components > I use (Struts? toplink? jdbc?), but don't know which one and I may be wrong. > If anybody has any idea on this problem please help. > -- > View this message in context: > http://www.nabble.com/Struts-1%3A-character-encoding-tp25766281p25766281.html > Sent from the Struts - User mailing list archive at Nabble.com. > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org > For additional commands, e-mail: user-h...@struts.apache.org
If you're using Tomcat and doing POST via URL, you need to change Tomcat's URL charset encoding. Default is ISO-8859-1, if I remember correctly. Regards, Tommy --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org