Hi Prabhu Mannu.
Answer below.

Prabhu Mannu wrote:
Hi all/ Dear André Warnier,

I understand that I cannot ask questions or help without actually telling
what I did so resolve the issue in the first place.

Initially I followed this
http://wiki.apache.org/tomcat/FAQ/CharacterEncoding

I wanted to get the minimal setting which would help, some of the things I
found is that few of the jsp pages itself was encoded differently and not
utf-8 and once I fixed that it do not completely worked.
After lots of trial and error,  Two  settings which worked for me are by
adding contenttype tag in  jsp page
<%@ page contentType="text/html; charset=UTF-8" %>
And in server.xml
<Connector connectionTimeout="20000" port="8089" protocol="HTTP/1.1"
redirectPort="8443" URIEncoding="UTF-8" />

Before changes to config
prabhu@dev01 ~
$ curl -I http://localhost:8088/xxxx/user/index.action
HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Set-Cookie: JSESSIONID=5CB483D8DC5F2C574DBDDE1E102763EC; Path=/xxxxx/;
HttpOnly
Content-Type: text/html;charset=ISO-8859-1
Content-Length: 3863
Date: Fri, 23 Jan 2015 09:14:43 GMT

After changes to config
prabhu@dev01 ~
$ curl -I http://localhost:8088/ xxxx /user/index.action
HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Set-Cookie: JSESSIONID=7CBEAE0ACCEB65FAF92CF6D94BF0FEDD; Path=/ xxxx /;
HttpOnly
Content-Type: text/html;charset=UTF-8
Content-Length: 3868
Date: Fri, 23 Jan 2015 09:15:12 GMT


With regards
Prabhu

My original answer was meant to be somewhat humoristic.
But that does not mean that your question to the list was "noob".
It was actually a good question, and a good explanation of your problem.
Bonus points for that.
That you found the solution yourself afterward, and communicated this to the list, are two additional bonus points. A part of what I wanted to say in my original answer, is that just by taking the time to actually think about the problem you are having, and writing down a clear explanation for someone else, you often find the solution yourself. Many people do not take that time, and fire incomplete and confusing messages to the list, which is not your case.

Some data about your original issue :

1) when it receives some response content from a webserver, according to the HTTP RFC's, a browser is supposed to (MUST) "believe" the content-type that the webserver is sending along with the response (in the "Content-type" header). Not all browsers do that correctly. Older versions of IE ignore this requirement, and try to figure out the content themselves. That is not good and often brings problems.

2) when the webserver does not send a Content-type header, then (and only then) the browser is allowed to "guess", based on inspecting the content.

3) when your application specifies the content-type (such as with the added parameters in the jsp tag), then the webserver (Tomcat here), will respect that, and send out the answer with a corresponding Content-type header. And then also a respectful browser will respect this too, and display the page in the correct character set.

4) when your application does not specify a content-type, then the webserver also "guesses" before sending out the response to the browser. And. beause the standard default charset of the HTTP 1.1 protocol is still "iso-8859-1", that is what the webserver guesses (wrongly) in this case. (Your first example of curl above).

Morality : in web applications, always specify the content-type (and character set, if applicable) of what you are returning.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to