JSP, Arabic text and Oracle

J

javadev

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
 
J

javadev

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

javadev

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?
 
A

Andrew Thompson

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

Lew

javadev said:
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
 
A

Andrew Thompson

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

Lew

Andrew said:
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
 
J

javadev

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

Lew

javadev said:
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
 
A

arad

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
 

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

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top