Expand my Community achievements bar.

JCR/POST encoding issue with characters like ľ š Ä\x8D Å¥....

Avatar

Level 2

Hello everyone,

this is second post here, but now i have little bit more information this time.

I am still experiencing encoding issue when AEM/Sling is saving POST request to JCR.

Apache Sling request parameter handling - Default Parameter Encoding - is set to UTF-8

I have tried code attached below on instances of sling & AEM. Here are my results:

  • (instance) - (Default parameter encoding setting) - (without _charset_ in request/ with _charset_ in request)
  • Sling - not set - broken/working
  • Sling - UTF-8 - working/working
  • AEM(clean installation) - not set - broken/working
  • AEM(clean installation) - UTF-8 - broken/working
  • AEM(with our code) - UTF-8 - broken/working

We have also tried to set encoding of the request in the filters but it was not working.

Example after running both FORMs from code below:

<%@ page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8" language="java" %> <% response.setCharacterEncoding("UTF-8"); %> <html > <head> <meta charset="UTF-8"> <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"> </head> <body> <form method="POST" action="/content/joz/jcr:content" enctype="multipart/form-data"> text:<input type="text" name="textWith" value="ľ š č Å¥ ž ý á í"/><br> <input type="text" name="_charset_" value="UTF-8"><br><br> <input type="Submit" /> </form> <br><br><br><br> <form method="POST" action="/content/joz/jcr:content" enctype="multipart/form-data"> text:<input type="text" name="textWithout" value="ľ š č Å¥ ž ý á í"/><br> <input type="Submit" /> </form> <br><br><br><br> <form method="POST" action="/content/joz/jcr:content" enctype="multipart/form-data"> DELETE <input type="hidden" name="textWithout@Delete" value="delete text" /> <input type="hidden" name="textWith@Delete" value="delete text" /><br> <input type="Submit" /> </form> </body> </html>

I don't really know what more can I do to solve this issue.

Is there any Encoding config for JCR, servlet or anything else?

Thanks for any help.

2 Replies

Avatar

Level 4

Our problem is more weird than this, our exact the same code and form work on author, but when submit through publisher, no matter what's the trick you listed below, the Spanish character in the submitted input fields messed. The final solution is when AEM start, put  -Dfile.encoding=UTF-8 in the aem start command, then problem resolved.

Avatar

Level 4
Sorry, revert back, the input is not correct. The current solution is write our own servlet to save/retrive the data to database ourselves then update JCR as needed. The AEM servlet code is very old and simple and may not fit the need.