Skip to Main Content

Integration

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Arabic language support in Sun java web server

807567Sep 3 2007 — edited Sep 14 2007
HI,

I need some help for configuring Arabic support.I am describing various configuration I have tried till today

Oracle Database: I am using 10g database.we have did following configuration on database

1. NLS_LANGUAGE = AMERICAN
2. NLS_TERRITORY = AMERICA
3. NLS_CHARACTERSET = AR8ISO8859P6 as well as AR8MSWIN1256

Database store Arabic data if data entered through sqlplus & web site on windows (which will be deployed on IIS server). if data entered through same website but deployed on sun one asp server (solaris machine), junk characters are going into database.

On solaris machine:
1. NLS_LANG : AMERICAN_AMERICA.AR8MSWIN1256
2. Arabic language package is installed on Solaris machine

On client (from where web site is accessed):

1. NLS_LANG : AMERICAN_AMERICA.AR8MSWIN1256
2. Arabic regional settings are installed on client machine.

Following encoding is tried on web server & web pages (in <meta> tag) :
UTF-8 and Cp1256 (encoding for arabic data)

We got some breakthrough using above configuration, but not complete solution.
: when Arabic data is entered through JSP web application into database.Arabic data is saved as it is.But when we Fetch same data from database and
display on page then junk characters displayed. For this we set parameter encoding to Cp1256 in deployment descriptor of JSP web application

If same data is displayed on page before saving into database then also junk characters are displayed on page

If we try to display Arabic static data written in html tags and JSP code.then also junk characters displayed on page


Please help me to solve this problem.Its very URGENT

Let me know if you need any help from my side



Thanks & Regards,
LMB

Comments

807567
Can u give the contents of sun-web.xml.
807567
It is preferable that you use UTF-8 encoding instead of cp1256 or iso-8858-6 encodings.
First, before even writing to database ensure that you are able to input and display Arabic characters in you web application.
The sample jsp code test.jsp which uses UTF-8 encoding is

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

<html>
<head>
        <title>Test</title>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>

<body dir=rtl>

<%
request.setCharacterEncoding("UTF-8");
String str = "\u0635\u0648\u0631";
String name = request.getParameter("name");
%>

Request Encoding: <%= request.getCharacterEncoding() %><br />
Response Encoding: <%= response.getCharacterEncoding() %><br />
str: <%= str %><br />
name: <%= name %><br />

<form method="GET" action="test.jsp">
Name: <input type="text" name="name" value="" >
<input type="submit" name="submit" value="Submit" />
</form>
</body>
</html>
-------------

Store the data in Oracle DB in UTF-8 encoding. You could try setting

set NLS_LANG=ARABIC_UNITED ARAB EMIRATES.UTF8
807567
Hi Sandycn
Thank you very much for your reply. I will try to follow your advise and let you know the result.. I am away from the server access for few days.

Rgds
LMB
807567
hi
i have the same problem and i tried your code and work correctly
but when i try to to get jsp parameter into servlet then send this parameter to another jsp, it make arabaic problem

plz help me on how cn i deal with this in servlet
if you can send me code for servlet take parameter like req.getparameter() and thin send vlues to another jsp with supportting to arabic langyage
thank you very much
807567
Here is some sample code.

1) Access the myjsp1.jsp and input some Arabic text. The encoding is specified as UTF-8 so when the form is submitted the characters will be encoded in UTF-8.

myjsp1.jsp
<%@ page contentType="text/html; charset=UTF-8" %>

<html>
<form method="GET" action="myServlet2">
Name: <input type="text" name="name" value="" >
<input type="submit" name="submit" value="Submit" />
</form>
</body>
</html>

2) The servlet myServlet2.java needs to know in which encoding the data is to be read. You specify this by calling setCharacterEncoding() method on the Request object. You need to call this method before calling getParameter(). Forward to myjsp2.jsp

myServlet2.java
...
public void doGet (HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
req.setCharacterEncoding("UTF-8");
//Read the parameters
String strValue = = req.getParameter("name");
//Can even set it as attribute
req.setAttribute("attr1", strValue);
....

//Forward to jsp
RequestDispatcher dispatcher;
dispatcher = getServletContext().getRequestDispatcher("/myjsp3.jsp");
dispatcher.forward(req, res);
}

3) In myjsp3.jsp the page encoding should be set so that the text is rendered correctly. The META http-equiv tag will indicate to the browser which encoding to use.

In myjsp3.jsp
<%@page pageEncoding="UTF-8" contentType="text/html; charset=UTF-8" %>
<html>
<head>
<META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=UTF-8">
<title>Test</title>
</head>
<body>
Arabic test
The Entered Name is : <%= request.getParameter("name") %>
Name is : <%= request.getAttribute("attr1") %>
</body>
</html>

Hope this helps.
1 - 5
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Oct 12 2007
Added on Sep 3 2007
5 comments
753 views