The method to change the character encoding for GET parameters will be different for each web server, so you will need to consult your web server docs.
For Apache Tomcat specifically, the solution is very easy. There are two different settings that can be applied to Tomcat to force it to change the character encoding used to decode GET parameters. They both involve modifying the <Connector> element in the Tomcat server.xml file.
- To force all request parameters to use a specific character encoding such as UTF-8, add the
URIEncodingattribute to the <Connector> element in the Tomcat server.xml file and set it to the desired value (e.g. URIEncoding="UTF-8").
- To force Tomcat to use the character encoding defined in the request, add the
useBodyEncodingForURIattribute to the <Connector> element in the Tomcat server.xml file and set it to true (e.g. useBodyEncodingForURI="true").
Here is an example of how the server decodes the following GET parameter before and after adding the encoding attribute to the <Connector> element.
- GET parameter: é (French lower case e acute)
- Before setting the encoding attribute, decoded as: Ã©
- After setting the encoding attribute to UTF-8, decoded as: é