This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Struts and the fly likes utf-8 on actionform Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "utf-8 on actionform" Watch "utf-8 on actionform" New topic
Author

utf-8 on actionform

Roberto Lopez Lopez
Greenhorn

Joined: Jun 16, 2008
Posts: 22
Hi.

I need to use utf-8 on my form. The JSP shows non-ascii characters well, but when I get back into my action I can't get the values from my attributes on utf-8. I'm sure the problem is only on the form, because I can get utf-8 strings from my resources file and display it properly. For example:

14:33:57,312 INFO [STDOUT] 43 - Siguiente subcategor��a - Siguiente subcategor�a


Where I get the text before the '-' from my form, and the text after from my resources file.

I'm declaring utf8 on my JSP as following:



Can anybody help? Thanks in advance...
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
I don't believe that UTF-8 is the right value to use as character set for European languages. Try ISO-8859-1 instead.


Merrill
Consultant, Sima Solutions
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41155
    
  45
I think that "multipart/form-data: charset=utf-8" is not a valid enctype; the encoding can't be specified in this way. Generally, the browser will use whatever encoding the page was delivered in. So if the contentType is UTF-8, then it should use UTF-8 for the form submission.

To make this explicit you can use the "accept-charset" form attribute. At least, that's what the HTML standard says how it should happen.
[ June 24, 2008: Message edited by: Ulf Dittmer ]

Ping & DNS - my free Android networking tools app
Roberto Lopez Lopez
Greenhorn

Joined: Jun 16, 2008
Posts: 22
@Merrill: ask my boss, it's one of the requirements...

The JSP has now these lines:



But the data from the form keeps "Siguiente subcategor��a" instead of "Siguiente subcategor�a". I've tried with other html:form attributes, but simply can't avoid this error. Any idea there? Is there another way to define the encoding?
Roberto Lopez Lopez
Greenhorn

Joined: Jun 16, 2008
Posts: 22
SOLVED:

JBoss sends everything in ISO-8859-1, even if I say UTF-8 on the jsp. I wrote a method to traduce every message into UTF-8.





Now I'm writing a filter to automatically traduce everything without need to call this method.

Thanks for your support!!!

Reference:http://www.jboss.com/index.html?module=bb&op=viewtopic&t=84678#3952987
Patrick Houston
Greenhorn

Joined: Aug 02, 2007
Posts: 2
The problem can be solved by adding the following code to the actionform reset and validate methods:
 
wood burning stoves
 
subject: utf-8 on actionform
 
Similar Threads
Soap turning non-ascii chars to garbage
Apache commons UTF-8 problem.
Struts 1.1 using RAD7
Internationalization (specifically with Chinese characters)
cannot use utf-8 to store utf-8 character, please help