File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "utf-8 on actionform" Watch "utf-8 on actionform" New topic

utf-8 on actionform

Roberto Lopez Lopez

Joined: Jun 16, 2008
Posts: 22

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.

Consultant, Sima Solutions
Ulf Dittmer

Joined: Mar 22, 2005
Posts: 42965
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 ]
Roberto Lopez Lopez

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

Joined: Jun 16, 2008
Posts: 22

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!!!

Patrick Houston

Joined: Aug 02, 2007
Posts: 2
The problem can be solved by adding the following code to the actionform reset and validate methods:
I agree. Here's the link:
subject: utf-8 on actionform
It's not a secret anymore!