Francois Cournoyer
Francois Cournoyer

Reputation: 174

AEM/CQ5 Request Parameter not UTF-8

Have a slight issue with AEM 6.0 SP1 and the search component. If searching for a french word like "Français" the "ç" gets messed up

the query string is like ?q=Français on the JSP side, request.getCharacterEncoding() returns ISO-8859-1 instead of UTF-8 like we need.

I know that when under tomcat you can change the URIEncoding at the connector level.

But for an AEM/CQ instance running directly by itself, there is no such thing. Anyone figured this out?

Upvotes: 2

Views: 4392

Answers (3)

Satish ch
Satish ch

Reputation: 21

enter image description here

Need to add the Default charset change as part of response header. Here is the detailed process

http://localhost:4502/system/console/configMgr
 -->Apache Sling Main Servlet 
    -->     Additional response headers add the below entry
                 Content-Type=text/html;charset=utf-8

Upvotes: 1

Sharath Madappa
Sharath Madappa

Reputation: 3402

For 5.6.1 : The default encoding can be set in the configuration of Apache Sling Main Servlet . In the Configuration Manager (<domain>:<port>/system/console/configMgr) look for Apache Sling Main Servlet and configure Default Parameter Encoding property.

enter image description here

For 6.0 (credits - Francois Cournoyer) : The configuration has been moved to Apache Sling Request Parameter Handling

Configure Temporary File Location to point to an absolute path in case of errors while saving the configuration

enter image description here

Upvotes: 9

Thomas
Thomas

Reputation: 7068

For forms within CQ always have a hidden field with the charset set to UTF-8 or the charset of your HTML:

<input type="hidden" name="_charset_" value="UTF-8"/>

This will ensure proper encoding when the servlet retrieves the post.

Upvotes: 1

Related Questions