Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set request character encoding of JSF input submitted values to UTF-8 in GlassFish

I have a problem with the values inserted in all my <h:inputText> fields. Some characters are not encoded in the right way. E.g. if I put ciò in the input field I get ciò.

How can I allow a user to insert text with those characters and save them correctly? The problem in not in the DB encoding since I already have the wrong value before inserting it in the DB.

I'm using JSF 2 with Facelets and GlassFish as application server.

like image 443
Evelina Agostini Avatar asked Mar 13 '12 10:03

Evelina Agostini


1 Answers

You need to tell Glassfish to use UTF-8 to decode paramters instead of (default) ISO 8859-1. Add the following entry to the <glassfish-web-app> of your /WEB-INF/glassfish-web.xml file:

<parameter-encoding default-charset="UTF-8" />
like image 179
BalusC Avatar answered Sep 19 '22 15:09

BalusC