JSP, Arabic text and Oracle

Discussion in 'Java' started by javadev, Feb 7, 2007.

  1. javadev

    javadev Guest

    I have a problem saving Arabic text entered through a JSP into the
    Oracle database.

    The NLS_LANG parameter for the database is AMERICAN_AMERICA.AL32UTF8.
    Do I need to change this value to something else?

    I have set the character encoding on my JSPs to UTF-8 as well as set
    the charset to UTF-8.

    <%@page contentType="text/html; charset=utf-8; language=java" %>
    <%@ page encoding="UTF-8" %>

    request.setCharacterEncoding("UTF-8");

    Despite all this, when I enter Arabic text in the JSP page and submit
    it, the text stored in the database is garbled. But if I try inserting
    Arabic text directly in the database (i.e. not through JSP) it gets
    stored fine.

    Any ideas on what could be causing the problem and how I can solve
    it?

    Any help will be greatly appreciated.

    Thanks
    Swetha
     
    javadev, Feb 7, 2007
    #1
    1. Advertising

  2. javadev

    javadev Guest

    Well it doesn't seem like a problem with the database, because the
    value is garbled when I retrieve it as a request parameter value on
    the action JSP. The request object is encoded as UTF-8 but the value
    retrieved is junk.
     
    javadev, Feb 12, 2007
    #2
    1. Advertising

  3. javadev

    javadev Guest

    Something very strange just happened... When I change the form method
    to "get" the Arabic text passed as a request parameter is retrieved
    fine on the action jsp.

    It seems there a problem with posting the form which is creating the
    problem. Why is this happening?
     
    javadev, Feb 12, 2007
    #3
  4. On Feb 7, 10:18 pm, "javadev" <> wrote:
    > I have a problem saving Arabic text entered through a JSP into the
    > Oracle database.


    This probably come down to the
    HTML, but since we have any number
    of J2EE gurus about these parts
    that bark at me whenever I suggest
    that folks asking such questions do
    so on an HTML group, I ignored the
    thread at first - to give them some
    time/space to sort this.

    (looks around..)

    OK, lets have a look at it..

    > I have set the character encoding on my JSPs to UTF-8 as well as set
    > the charset to UTF-8.


    Uh-Huh..

    > <%@page contentType="text/html; charset=utf-8; language=java" %>


    Ummm.. The server might 'speak' Java,
    but the 'language' is intended to indicate
    the language of the document *content*.

    I am not sure if DTD based validation
    goes as far as checking language
    attributes, but you might give it
    a try at..
    <http://validator.w3.org/>

    Further, I strongly suggest you get a
    static version of a page (i.e. HTML)
    working, and validated, before
    attempting to do it as JSP or a servlet.
    If having problems with the Java side
    of it, check the output exactly matches
    the HTML being produced.

    HTH

    Andrew T.
     
    Andrew Thompson, Feb 12, 2007
    #4
  5. javadev

    Lew Guest

    javadev wrote:
    > Something very strange just happened... When I change the form method
    > to "get" the Arabic text passed as a request parameter is retrieved
    > fine on the action jsp.
    >
    > It seems there a problem with posting the form which is creating the
    > problem. Why is this happening?


    There is a nearly identical question going on in clj.help entitled
    "Arabic text in posted form and JSP"

    that may have relevant information for you.

    - Lew
     
    Lew, Feb 12, 2007
    #5
  6. On Feb 13, 12:52 am, Lew <> wrote:
    > javadev wrote:
    > > Something very strange just happened... When I change the form method
    > > to "get" the Arabic text passed as a request parameter is retrieved
    > > fine on the action jsp.

    >
    > > It seems there a problem with posting the form which is creating the
    > > problem. Why is this happening?

    >
    > There is a nearly identical question going on in clj.help entitled
    > "Arabic text in posted form and JSP"
    >
    > that may have relevant information for you.


    It was probably not a good strategy, to
    repost the question from here to c.l.j.help,
    *unless* if perhaps you had posted *here*
    saying you'd found a more appropriate
    group for your enquiry "after waiting
    4 days for no reply here, am moving
    thread to c.l.j.help group", and
    *mentioning* on the new thread, that the
    old thread existed and had not been
    successful.

    If you had done that, I am guessing
    that Lew (who, as an aside, knows
    a whole heap more about server-side
    development than I do, and also posts
    to both groups), would have helped
    you willingly, rather than directing
    you back to your own thread.

    Andrew T.
     
    Andrew Thompson, Feb 12, 2007
    #6
  7. javadev

    Lew Guest

    Andrew Thompson wrote:
    > On Feb 13, 12:52 am, Lew <> wrote:
    >> javadev wrote:
    >>> Something very strange just happened... When I change the form method
    >>> to "get" the Arabic text passed as a request parameter is retrieved
    >>> fine on the action jsp.
    >>> It seems there a problem with posting the form which is creating the
    >>> problem. Why is this happening?

    >> There is a nearly identical question going on in clj.help entitled
    >> "Arabic text in posted form and JSP"
    >>
    >> that may have relevant information for you.

    >
    > It was probably not a good strategy, to
    > repost the question from here to c.l.j.help,
    > *unless* if perhaps you had posted *here*
    > saying you'd found a more appropriate
    > group for your enquiry "after waiting
    > 4 days for no reply here, am moving
    > thread to c.l.j.help group", and
    > *mentioning* on the new thread, that the
    > old thread existed and had not been
    > successful.
    >
    > If you had done that, I am guessing
    > that Lew (who, as an aside, knows
    > a whole heap more about server-side
    > development than I do, and also posts
    > to both groups), would have helped
    > you willingly, rather than directing
    > you back to your own thread.


    The aliases differ, so I didn't [overtly] assume that it was the same poster.

    - Lew
     
    Lew, Feb 12, 2007
    #7
  8. javadev

    javadev Guest

    Well I'm sorry about the cross-post, but I dont think this case was as
    offensive as it's being made out to be, considering that there was
    absolutely no activity on this thread until a couple of hours back. I
    was only looking for some help and I'm sorry if I rubbed a few
    shoulders the wrong way in the process.

    Coming back to the problem at hand, I seem to have found a work-around
    for now:

    I retrieve the request parameters, encode the resulting string into a
    sequence of bytes using "8859_1" charset and then construct a new
    String by decoding this array of bytes using "UTF-8". This seems to be
    working now, but it still isnt the perfect solution.
     
    javadev, Feb 12, 2007
    #8
  9. javadev

    Lew Guest

    javadev wrote:
    > Well I'm sorry about the cross-post, but I dont think this case was as
    > offensive as it's being made out to be, considering that there was
    > absolutely no activity on this thread until a couple of hours back. I
    > was only looking for some help and I'm sorry if I rubbed a few
    > shoulders the wrong way in the process.


    You didn't cross post, you multi-posted. Cross posting would have been all right.

    The problem with multi-posting is that you fragment the thread and lose help.
    Also, this is not a help desk, so if there is "absolutely no activity" then go
    back to doing your own research.

    Furthermore, as Andrew suggested, if you feel you absolutely cannot go one
    more New York minute without multi-posting that you *say so* in your
    multi-post, explain it and direct people to answer in your preferred thread.
    Better yet, *cross post* a reply to your own thread to bring in the other
    newsgroup.

    Otherwise you will be out of luck getting answers. People will not waste their
    time on multiposted questions because they know the thread is fragmented.

    Just trying to help. It isn't about whether you "rubbed a few shoulders"
    (which, btw, is an idiom meaning "to associate [with]", not "to irritate") but
    about what will get you the results you want. So forget about thinking it's a
    question of multi-posting being "offensive", because it isn't, but whether
    it's effective.

    - Lew
     
    Lew, Feb 12, 2007
    #9
  10. javadev

    arad Guest

    On Feb 12, 4:52 pm, Lew <> wrote:
    > javadev wrote:
    > > Something very strange just happened... When I change the form method
    > > to "get" the Arabic text passed as a request parameter is retrieved
    > > fine on the action jsp.

    >
    > > It seems there a problem with posting the form which is creating the
    > > problem. Why is this happening?

    >
    > There is a nearly identical question going on in clj.help entitled
    > "Arabic text in posted form and JSP"
    >
    > that may have relevant information for you.
    >
    > - Lew


    change the nls_lang to arabic
     
    arad, Feb 12, 2007
    #10
    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:
    795
    Juan T. Llibre
    Sep 11, 2005
  2. Alex Nazarian

    Arabic Text Rendering

    Alex Nazarian, Oct 26, 2004, in forum: Java
    Replies:
    9
    Views:
    5,416
    Andrew Thompson
    Oct 28, 2004
  3. Swetha
    Replies:
    16
    Views:
    7,568
    Roedy Green
    Dec 13, 2005
  4. Steve Rainbird

    jsp arabic text problem

    Steve Rainbird, Jul 7, 2006, in forum: Java
    Replies:
    3
    Views:
    5,793
    Harri Tuuloskoski
    Jul 14, 2006
  5. Feyruz
    Replies:
    4
    Views:
    2,243
    Sherm Pendley
    Oct 14, 2005
Loading...

Share This Page