|
|
There's large simularity in the way data travels from and to a web server. But unfortunately there is one difference: while the web server tells the browser what character encoding the page it sends is in (the "page contentType="text/html;charset=UTF-8" language="java"" line at the beginning of each .jsp page of MOAP), the client does not send such information.
The browser generally does the following:
1 - it takes user input in national characters
2 - translates it to a byte sequence using the character encoding that the web page that contains the form is encoded (the "charset=UTF-8" specified in the jsp page).
3 - sends the query to the server.
Accordingly to the HTTP spec the HTTP request the browser send to the server (that contains the submitted form) may well contain the Content-Type header too. This would give the server the key to decript the form parameters. Regretfully our present internet browsers do not send it (it is a known issue).
From Servlet 2.3 Filter mechanism was introduced and setCharacterEncoding() method was added to the ServletRequest. In a few words, it makes it possible to set character encoding inside the filter before the request's parameters is parsed.
This filter sets the character encoding before parameters are handled, and allow any language to be stored and retrieve correctly using UTF-8 encoding and UNICODE.
This class is the basis for character enconding. It sets the enconding of the request to UTF-8 according to the filters.xml and filter-mappings.xml parameters file.
-- JordaneRollin - 05 Apr 2004
|
|