Problem: FormPanel / FileUpload - special characters and german umlauts

631 views
Skip to first unread message

GWT-Newbie

unread,
Nov 13, 2009, 4:46:25 AM11/13/09
to Google Web Toolkit
Hey there,

using the FormPanel with the FileUpload widget, the strings from the
TextBoxes and TextAreas of my FormPanel don't support some special
characters and german umlauts.
On the client-side everything is okay, but arriving at the server, the
characters and umlauts (like ä ü ö) were replaced e.g. with s.th. like
"ü � ä ö ü" and so on.
My server-side will send eMails with those Strings and I would like to
have them correctly.
Can anyone of you guys help me? Would be great!

Cheers!

Thomas Broyer

unread,
Nov 13, 2009, 10:33:45 AM11/13/09
to Google Web Toolkit
This looks like UTF-8 being interpreted as if it were Latin-1 (or
similar // ISO-8859-1 or similar). Check your server-side code.

GWT-Newbie

unread,
Nov 17, 2009, 4:31:52 AM11/17/09
to Google Web Toolkit
On the client side, I did "uploadForm.setEncoding
(FormPanel.ENCODING_MULTIPART);"
In the server code, I have nothing like a encoding or a charset
setting.

I have no idea to fix it, dan anyone help me?

GWT-Newbie

unread,
Nov 17, 2009, 5:51:04 AM11/17/09
to Google Web Toolkit
I tried request.setCharacterEncoding(text/hmtl; UTF-8" and got the
same result. -.-

Martin Trummer

unread,
Nov 17, 2009, 9:31:18 AM11/17/09
to Google Web Toolkit
check that your html file has the correct content type:
<meta http-equiv="content-type" content="text/html; charset=UTF-8">

then put a breakpoint in your servlet and check if the special chars
are still ok

and make sure, to use the correct method on your form
setMethod(FormPanel.METHOD_POST)

GWT-Newbie

unread,
Nov 18, 2009, 4:18:44 AM11/18/09
to Google Web Toolkit
Thanks for your answer!

My html file has the correct type and I am using the correct method on
your form.
In the Client, the special chars of the FormPanel items are still ok,
before it's submitted. (e.g. "Grüße")
If I get the Strings of the submitted items in the servlet
(item.getString()), the special chars are wrong. (Grüße -> "GrüÃ?e")

I have no more idea to solve my problem...

Martin Trummer

unread,
Nov 18, 2009, 5:40:23 AM11/18/09
to Google Web Toolkit
what does request.getCharacterEncoding() show?

if you use commons-file upload, you could try to manually set the
encoding
upload.setHeaderEncoding(encoding) --> to the same value you use in
your meta tag

GWT-Newbie

unread,
Nov 18, 2009, 7:20:53 AM11/18/09
to Google Web Toolkit
Yes, I'm using commons-file upload.

My meta tag is: <meta http-equiv="content-type" content="text/html;
charset=UTF-8">
request.getCharacterEncoding() shows "UTF-8"
upload.getHeaderEncoding() now also shows "UTF-8"

But still getting the wrong result. -.-

Martin Trummer

unread,
Nov 18, 2009, 8:24:23 AM11/18/09
to Google Web Toolkit
hm - works for me

maybe you should make a simple testapplication and post the
entry point class and a minimal version of your servlet

GWT-Newbie

unread,
Nov 19, 2009, 2:15:09 AM11/19/09
to Google Web Toolkit
Solved the problem :)

It wasn't the GWT making complications, the chars arrived at the
server correctly, but were misinterpreted by Apache Commons Fileupload
reading the items with the filItem.getString()-Method.
In addition to upload.setHeaderEncoding("UTF-8"), I had to add a
argument to every getString() method, which says, that he mustn't use
the american ASCII, but UTF-8. (fileItem.getString("UTF-8"))
Thanks for your attempt!

Happy coding.
Reply all
Reply to author
Forward
0 new messages