I am having problems to change the charset in my web application response from ISO-8859-1 (default) to UTF-8. I already added the VM option -Dfile.encoding=UTF-8
to the JVM options
But still, I do get the following HTTP Header as a response from the glassfish:
Content-Type: [...;charset=ISO-8859-1]
Server: [GlassFish Server Open Source Edition 3.1]
I would appreciate your help/ideas.
The -Dfile.encoding
is a Oracle JVM specific setting as to how to read Java source files. This doesn't have any influence on the charset as specified in the Content-Type
header of the HTTP response.
You need to add the following to your web.xml
in order to send the response of all JSPs as UTF-8 and to let it set the appropriate charset in the response header.
<jsp-config>
<jsp-property-group>
<url-pattern>*.jsp</url-pattern>
<page-encoding>UTF-8</page-encoding>
</jsp-property-group>
</jsp-config>
For UTF-8 fonts on Glassfish3 (Log files, etc):
Go to Server-config
> JVM Settings
> JVM Options
> Add option
(-Dfile.encoding=UTF8
).
If you are not on -server mode
then go to default-config
> JVM Settings
> JVM Options
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With