• Post Reply Bookmark Topic Watch Topic
  • New Topic

Character encoding problem on first request  RSS feed

 
KC Smith
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm encountering some strange behavior in a i18n Struts application. All of my jsp pages use utf-8 encoding.

<%@ page language="java" contentType="text/html; charset=UTF-8" %>

When non-English languages with special characters are displayed, the special characters are garbled BUT only on the first request within a session. Afterwards all requests display all characters fine. If the user closes the browser and reopens the site, the process begins again.

Anyone have any ideas how to display the characters correctly the first time?

Thanks for your help.
 
Mark Vedder
Ranch Hand
Posts: 624
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Our team once ran into an issue where although the charset of the JSP pages was set to UTF-8, the editor that was used to create the pages used the windows default charset when saving the pages. This caused an issue with the particular web server we were using resulting in a lot of garbage text. The solution for us was to re-create the files, ensuring they were saved as UTF-8. (Changing the <%@ page%> tag's charset to ISO-8859-1 also resolved the issue as the file and display character sets now "matched" and since at the time we only had western based languages; but we obviously lost the benefit that UTF-8 provided if we needed to localize the page for any Asian or Middle East languages, so we decided to recreate all the files as mentioned.)

I am not sure if that will help you any since it may have been an issue specific to our web server, but I thought I might offer it as a suggestion.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!