A simple HTML file:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<form method="POST" action="test.jsp" accept-charset="utf-8" method="post" enctype="application/x-www-form-urlencoded" >
<input type="text" name="P"/>
<input type="submit" value="subMit"/>
</form>
</body>
</html>
The HTML file is served by the server using header Content-Type:text/html; charset=utf-8
. Everything says: "dear browser when you post this form, please post it utf-8 encoded". The browser actually does this. Every value entered in the input field will be UTF-8 encoded. BUT the browser wont tell this to the server! The HTTP header of the post request will contain a Content-Type:application/x-www-form-urlencoded
field but the charset will be omitted (tested with FF3.6 and IE8).
The problem is the application server I use (Tomcat6) expects the charset in the Content-Type header (as stated in RFC2388). Like this: Content-Type:application/x-www-form-urlencoded;charset=utf-8
. If the charset is omitted it will assume ISO-8859-1 which is not the charset used for encoding. The result is broken data.
Does some one have a clue how to force the current browsers to append the charset to the Content-Type header?