I have a problem that whenever I enter arabic text in a jsp input field it
gets garbled.
To test this I have written a jsp that just copies text from one box to
another and its garbled in the destination.
Please help me this is driving me mad!!
Any ideas gratefully received.
The jsp is below
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<%@ page contentType="text/html;charset=windows-1256"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=windows-1256"/>
<title>AAA</title>
<style type="text/css">
body {
background-color: #ffffff;
}
</style>
</head>
<%
String fromval, toval;
fromval = request.getParameter("FROM");
if(fromval != null && fromval.length() > 0) {
toval = fromval;
} else {
toval = "Default";
}
%>
<body><form name="AAA Sample" action="AAA.jsp" method="post"
enctype="application/x-www-form-urlencoded">
<p>
Sample Form.
</p>
<p>
Arabic text: ÈíÇäÇÊ ÇáÚãíá ÇáÑÆíÓíå
</p>
<p>
</p>
<p>
Copy from here:
<input type="text" name="FROM" maxlength="50" size="50"
value="ÈíÇäÇÊ ÇáÚãíá ÇáÑÆíÓíå"/>
</p>
<p>
</p>
<p>
To here:<input type="text" name="TO" maxlength="50" size="50"
value="<%=toval%>"/>
</p>
<p>
</p>
<p>
<input type="submit" name="Submit"/>
</p>
</form></body>
</html>

Signature
Steve
Remove "nospam" from email address to reply to me personally
Andrew T. - 07 Jul 2006 16:14 GMT
> I have a problem that whenever I enter arabic text in a jsp input field it
> gets garbled.
....
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
> "http://www.w3.org/TR/html4/loose.dtd">
[quoted text clipped - 10 lines]
> </style>
> </head>
Have you tried setting the language to Arabic?
http://www.w3.org/International/tutorials/language-decl/
Andrew T.
Steve Rainbird - 07 Jul 2006 16:22 GMT
>I have a problem that whenever I enter arabic text in a jsp input field it
>gets garbled.
<snip>
If I add the following line it now works
request.setCharacterEncoding("Cp1256");
This says it "Overrides the name of the character encoding used in the body
of this request.".
How do I set this by default?

Signature
Steve
Remove "nospam" from email address to reply to me personally
Harri Tuuloskoski - 14 Jul 2006 19:32 GMT
> I have a problem that whenever I enter arabic text in a jsp input field it
> gets garbled.
[quoted text clipped - 7 lines]
>
> The jsp is below
To prevent encoding problems, use UTF-8 encoding in page and all fields.
Then you just need to read everything in UTF-8. Works like wonders.
--
Harri