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();
    List<byte> token;
    token.add((byte) c);
    byte[] ba = new byte[token.size()];
    for (int i=0; i<token.size(); 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
"&amp;#37670;&amp;#27743;" (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

Reply via email to