jide85
asked on
Cross platform web app character encoding problems
Hello Experts.
I'm currently working on an web application that runs with UTF-8 encoding.
I'm running my web application on a resin 2.0.27. My web app is a spring mvc application which receives a couple of parameters when an user invokes a servlet with a specific url. The application then asks the index, which in turn returns data for my application to present to the user.
My problem is as follows:
When specifying in my resin conf that the resin instance should run with UTF-8 character encoding characters like åäö works fine in my linux environment(firefox). But when calling the application from a windows environment(firefox, IE) all parameters which contains å ä ö gets ignored by the request object. When sending the correct utf-8 encoding(%C3%B6 instead of ö) then everything works fine.
If i don't specify UTF-8 in my resin conf then all parameters exist inte the request object but the encoding gets all wrong in the linux environment and the web application receives junk characters such as ö->ö.
But when calling the application from windows å ä ö gets iso encoded(ö -> %F6 )
and works fine.
What I'm i doing wrong, why do this problem occur?
Could you please help me figure this out.
I'm currently working on an web application that runs with UTF-8 encoding.
I'm running my web application on a resin 2.0.27. My web app is a spring mvc application which receives a couple of parameters when an user invokes a servlet with a specific url. The application then asks the index, which in turn returns data for my application to present to the user.
My problem is as follows:
When specifying in my resin conf that the resin instance should run with UTF-8 character encoding characters like åäö works fine in my linux environment(firefox). But when calling the application from a windows environment(firefox, IE) all parameters which contains å ä ö gets ignored by the request object. When sending the correct utf-8 encoding(%C3%B6 instead of ö) then everything works fine.
If i don't specify UTF-8 in my resin conf then all parameters exist inte the request object but the encoding gets all wrong in the linux environment and the web application receives junk characters such as ö->ö.
But when calling the application from windows å ä ö gets iso encoded(ö -> %F6 )
and works fine.
What I'm i doing wrong, why do this problem occur?
Could you please help me figure this out.
ASKER
I'm invoking a servlet which receives the request object.
Like this
Search.do?q=städning&proce dure=öppen .
Like this
Search.do?q=städning&proce
But how is it getting that query string? It should be url-encoded. See java.net.URLEncoder
would suggest adding a CharacterEncodingFilter if you don't already
http://static.springframework.org/spring/docs/2.0.x/api/org/springframework/web/filter/CharacterEncodingFilter.html
http://static.springframework.org/spring/docs/2.0.x/api/org/springframework/web/filter/CharacterEncodingFilter.html
>>When sending the correct utf-8 encoding(%C3%B6 instead of ö) then everything works fine.
That's exactly how the url *should* be encoded
That's exactly how the url *should* be encoded
ASKER
But how is it getting that query string? It should be url-encoded. See java.net.URLEncoder
I'm not sure what you mean. Th query string is written into the web browsers search field.
A request to the web server is created with the paramaters. If a parameter=a word with å ä ö
the parameter do not get included to the request object. Why?
would suggest adding a CharacterEncodingFilter if you don't alreadyI have tried to impelent a filter
I have already implemented a filter to make sure that my request object get's the right encoding. What I discovered in this filter was that the parameters do not exist in the request object if they contain å ä ö. This must mean that resin is doing something with the parameters which contains åäö or?
I'm not sure what you mean. Th query string is written into the web browsers search field.
A request to the web server is created with the paramaters. If a parameter=a word with å ä ö
the parameter do not get included to the request object. Why?
would suggest adding a CharacterEncodingFilter if you don't alreadyI have tried to impelent a filter
I have already implemented a filter to make sure that my request object get's the right encoding. What I discovered in this filter was that the parameters do not exist in the request object if they contain å ä ö. This must mean that resin is doing something with the parameters which contains åäö or?
try using firebug to look at the details of the requests and response, in particular the encoding of them and the page
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you guys. What i did was that I implemented a filter which checks if the url is utf encoded.
If not then i decode the request object with ISO and encode it with UTF-8 and viola, no more
encoding issues.
If not then i decode the request object with ISO and encode it with UTF-8 and viola, no more
encoding issues.
In what way is the application called? What's the browser interface? If it's a <form> do you specify a UTF-8 charset?