| Author |
Struts and Chineese characters
|
syd kahn
Greenhorn
Joined: Aug 23, 2005
Posts: 12
|
|
I have a text field on a Struts form that i type 展中国家或经济处于 into. i send it out to as a mail message by appending the string variable to the output - the email gets garbled characters. I put the string variable into a database using a CallableStatement and setString - it gets to the DB garbled. I know the datbaase can handle it (SQL SERVER 2000) since that is where i copied the characters from in the first place. I am reading about getbytes() but am unsure of the usage or how to get the variable (which it says java deals with as utf-8) out to the databse/e-mail in the proper form in short - i'm stuck
|
 |
Wagner Danda Da Silva Filho
Ranch Hand
Joined: Mar 21, 2003
Posts: 80
|
|
Once I got problems with encoding in Struts, then I solve it after changing the page directive to the correct encoding. E.g.: <%@ page language="java" pageEncoding="UTF-8"%>
|
SCJP, SCWCD
|
 |
syd kahn
Greenhorn
Joined: Aug 23, 2005
Posts: 12
|
|
I found the answer to my problem here http://www.mail-archive.com/user@struts.apache.org/msg13132.html By the time you get a chance to deal with the variables Struts has already parsed the response(request?) stream - and mangled the characters. this is the source for a filter that forces UTF-8 before the struts framework gets it grimy little hands on it. The database insert now works - and the display page is good - just need to figure out how to get the charactes into the e-mail.... Thank G.D for GOOGLE....
|
 |
syd kahn
Greenhorn
Joined: Aug 23, 2005
Posts: 12
|
|
Now that I have the web pages and the database displayng the characters correctly - the email is now broken - it only shows ??? for the data - I am using the jakarta commons (included in netbeans) and sending html mail. Is htere a way to tell it to accept UTF-8. I can see the varaible's content in the IDE as \23edr\1111\222 etc - but they are not finding their way into the email correctly. Any Ideas [ November 18, 2005: Message edited by: syd kahn ] [ November 18, 2005: Message edited by: syd kahn ]
|
 |
Nathan Pruett
Bartender
Joined: Oct 18, 2000
Posts: 4121
|
|
|
Moving to the Struts forum, since this seems to be a struts problem...
|
-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
|
 |
syd kahn
Greenhorn
Joined: Aug 23, 2005
Posts: 12
|
|
For those that have this problem - i was using the org.apache.commons.mail set of classes to send the mail. This is a wrapper around the javax.mail classes from sun all that i had to do was add the setCharset line to get it all working...
|
 |
 |
|
|
subject: Struts and Chineese characters
|
|
|