Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / July 2006

Tip: Looking for answers? Try searching our database.

jsp arabic text problem

Thread view: 
Steve Rainbird - 07 Jul 2006 15:58 GMT
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>

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


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.