jsp arabic text problem

Discussion in 'Java' started by Steve Rainbird, Jul 7, 2006.

  1. 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>

    --
    Steve

    Remove "nospam" from email address to reply to me personally
    Steve Rainbird, Jul 7, 2006
    #1
    1. Advertising

  2. Steve Rainbird

    Andrew T. Guest

    Steve Rainbird wrote:
    > 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.
    Andrew T., Jul 7, 2006
    #2
    1. Advertising

  3. "Steve Rainbird" <> wrote in message
    news:...
    >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?

    --
    Steve

    Remove "nospam" from email address to reply to me personally
    Steve Rainbird, Jul 7, 2006
    #3
  4. Steve Rainbird wrote:
    > 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.

    --
    Harri
    Harri Tuuloskoski, Jul 14, 2006
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. mansour via DotNetMonster.com

    when i try to insert or update text in arabic it appears "????"

    mansour via DotNetMonster.com, Sep 11, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    775
    Juan T. Llibre
    Sep 11, 2005
  2. Alex Nazarian

    Arabic Text Rendering

    Alex Nazarian, Oct 26, 2004, in forum: Java
    Replies:
    9
    Views:
    5,401
    Andrew Thompson
    Oct 28, 2004
  3. Swetha
    Replies:
    16
    Views:
    7,517
    Roedy Green
    Dec 13, 2005
  4. Khan
    Replies:
    4
    Views:
    3,430
  5. javadev

    JSP, Arabic text and Oracle

    javadev, Feb 7, 2007, in forum: Java
    Replies:
    9
    Views:
    1,041
Loading...

Share This Page