I'm using struts 1.1 as part of my web application, but I've hit some major character encoding issues! Why does struts automatically encode all of the strings placed directly into a given form bean as ISO-8859-1?
I've set all my JSPs to UTF-8 encoding, but the � symbol still renders incorrectly as �� if I look at the contents of my form bean. I can get out of this by doing the following
but this is a pain to do for all strings. I guess I could put a method to do this conversion in all of my entity beans, but this issue seems so fundamental that I feel I'm missing something.
Is this normal behaviour for struts, or is there a setting I require?
My reason for using UTF-8 encoding is that the � symbol seems to be rendered incorrectly by my JSPs (be it dynamic content or hard coded in the page) as �� when I use ISO-8859-1.
Any suggestions as to either solve the struts conversion problem, or how to render � correctly with ISO-8859-1 would be much appreciated.
Yah i agree that encoding is a big pain..............but i will tellu one way is u just want to display them in jsps correctly u can use <meta http-equiv="Content-Type" content="text/html; charset=urencoding what u need">
u need to place this in all the jsps whereever u need to dipslya that characters.........this will force the browsers endoing to the encoding u need.................
but i will tell if u want to read some files from the file systemw hich are stored with diff language then u need to go for encoing using jaba.lang.string ......and encode it to whatever u need
Help onencoding is very less if u get something u tell me i struggled like anything for this
Joined: Mar 04, 2003
I believe the issue I was experiencing was that all strings passed back to the server were assumed to be in ISO format, despite the page encoding being set to utf-8. As I now understand it, many browsers do not correctly support passing the encoding type of a response back to the server.
After much messing about with request/response setContentType(), <%@ page contentType="text/html; charset=utf-8" %> and modifying the Struts-config file I was having very little success until I found that there is an encoding filter included in Tomcat 5 (\jakarta-tomcat-5.0.19\webapps\servlets-examples\WEB-INF\classes\filters\SetCharacterEncodingFilter.java).
Implementing this has solved all my issues and everything seems to be carried as utf-8 now. Seeing as this corrected my issue, I assume the root cause was that the contentType of the request object was not being set correctly at some point in the application.
I've attached a few useful links below on the subject of encoding. Any comments on my fix or a definite cause of my issue would be appreciated.