Glassfish tips: default encoding

glasfish

Glassfish-Tips: UTF-8 Encoding

Glassfish 3.1.2 has default encoding ISO-8859-1. If you get a warning like below in Eclipse console (Server.log):

WARNING: PWC4011: Unable to set request character encoding to UTF-8 from context, because request parameters have already been read, or ServletRequest.getReader() has already been called

you can add parameter-encoding  in the sun-web.xml, or glassfish-web.xml as shown below:

<?xml version=”1.0″ encoding=”UTF-8″?>
<!DOCTYPE sun-web-app PUBLIC “-//Sun Microsystems, Inc.//DTD Application Server 9.0 Servlet 2.5//EN”
“http://www.sun.com/software/appserver/dtds/sun-web-app_2_5-0.dtd”>
<sun-web-app error-url=”">

<parameter-encoding default-charset=”UTF-8″/>
</sun-web-app>

Then your Glassfish server.log looks cleaner.