jsp arabic text problem

S

Steve Rainbird

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>
&nbsp;
</p>
<p>
Copy from here:
<input type="text" name="FROM" maxlength="50" size="50"
value="ÈíÇäÇÊ ÇáÚãíá ÇáÑÆíÓíå"/>
</p>
<p>
&nbsp;
</p>
<p>
To here:<input type="text" name="TO" maxlength="50" size="50"
value="<%=toval%>"/>
</p>
<p>
&nbsp;
</p>
<p>
<input type="submit" name="Submit"/>
</p>
</form></body>
</html>
 
A

Andrew T.

Steve said:
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">
<%@ 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>

Have you tried setting the language to Arabic?
http://www.w3.org/International/tutorials/language-decl/

Andrew T.
 
S

Steve Rainbird

Steve Rainbird said:
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?
 
H

Harri Tuuloskoski

Steve said:
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

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,820
Latest member
GilbertoA5

Latest Threads

Top