Solved

Cross platform web app character encoding problems

Posted on 2009-05-12
11
1,352 Views
Last Modified: 2013-11-11
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.
 
0
Comment
Question by:jide85
  • 5
  • 3
  • 3
11 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 24363854
>>But when calling the application from a windows environment

In what way is the application called? What's the browser interface? If it's a <form> do you specify a UTF-8 charset?
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 24363880
0
 
LVL 1

Author Comment

by:jide85
ID: 24363890
I'm invoking a servlet which receives the request object.
Like this
Search.do?q=städning&procedure=öppen.
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 24363925
But how is it getting that query string? It should be url-encoded. See java.net.URLEncoder
0
 
LVL 92

Expert Comment

by:objects
ID: 24363967
0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
LVL 86

Expert Comment

by:CEHJ
ID: 24364015
>>When sending the correct utf-8 encoding(%C3%B6 instead of ö) then everything works fine.

That's exactly how the url *should* be encoded
0
 
LVL 1

Author Comment

by:jide85
ID: 24372675
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 already
I 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?
0
 
LVL 92

Expert Comment

by:objects
ID: 24372712
try using firebug to look at the details of the requests and response, in particular the encoding of them and the page

0
 
LVL 86

Assisted Solution

by:CEHJ
CEHJ earned 100 total points
ID: 24374490
>>Th query string is written into the web browsers search field.

If you've got a search box then you have a search form presumably. Did you set the form attribute as i suggested earlier?
0
 
LVL 92

Accepted Solution

by:
objects earned 400 total points
ID: 24381870
0
 
LVL 1

Author Comment

by:jide85
ID: 24480349
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.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:

932 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now