0

I'm currently building a website I'm hosting on Heroku. While I love the hosting, I can't seem to get GET data to be UTF-8. When I run it locally, it works fine, but pushed to the Heroku servers it won't work.

The app is an Java Web application, all jsp pages are UTF-8 encoded, and I have a filter on all pages where the requestEncoding is UTF-8 as well. In the servlet, before I read the data, I put the encoding as request.setCharacterEncoding("UTF-8");

I'm running out of ideas, is there a simple thing I'm overlooking?

Cheers

Robbenu
  • 415
  • 4
  • 13
  • Can you post some additional detail about what you've tried? Specifically, data that did not render correctly, etc. At first glance, what you need to do is make sure the *response* content type is correct (you reference request, which is good, but you need to use both). This response may have some useful pointers for you: http://stackoverflow.com/questions/138948/how-to-get-utf-8-working-in-java-webapps – bimsapi Feb 23 '15 at 18:41
  • Hi there, thanks for replying! The data I entered that not rendered correctly were things like í, ä, ô etc. They get transfered into things like Ã. I've also tried setting the response content type, as well as adding utf-8 to the procfile needed for deploying in Heroku. I'm not sure if and where I can edit the Tomcat settings. From the post you sent (I also found that one) I've tried everything except the tomcat settings. – Robbenu Feb 24 '15 at 19:24
  • Are the accented characters hard-coded in the JSPs themselves, or is it user-entered data? If hard-coded, it may be worthwhile to sanity check the file encoding. On OS X or Linux, you can use the `file` command, as in `file my.jsp`, and get info back about encoding. – bimsapi Feb 25 '15 at 04:36
  • As said in the title, the accented characters are in the GET data. – Robbenu Feb 26 '15 at 06:37
  • Sorry I wasn't clear - I assume "GET data" means the response body generated for a GET request, in which case it could come from text hard-coded in the JSP or it could come from stored data that's retrieved from another source (database, property file, etc.). Can you share any code snippets? Specifically where you set content type, or where you are retrieving/returning the data? Another interesting thing to look at would be the headers to make sure Tomcat is honoring your setting - try `curl -i [your url]` or `wget -S [your url]`. Hope this helps. – bimsapi Feb 26 '15 at 14:53

1 Answers1

3

The support team of Heroku could answer my problem. If you are experiencing the same problem, this is the solution.

If you are using the latest version of webapp-runner (7.0.57.2), you can add the option --uri-encoding in your Procfile.

java ... -jar target/dependency/webapp-runner.jar --port $PORT --uri-encoding UTF-8 --expand-war target/*.war`
Robbenu
  • 415
  • 4
  • 13