Servlet Getting Parameter Value Problem!!!!!!Plz Help!!!!

Hi All,
I have a servlet servlet1,its output is an HTML page, this page (which of course built dynamically within servlet1) has a button which when clicked on it a javascript function(defined in this page)is called, this script draws another html page and call it in a seperate window as a dialog....(the drawing was done using the with and write tags). In this dialog There is a form which has a text field & a submit button,the user inters some data in this field..the data entered in the Arabic language. after entering his data & when submitting the form, another servlet servlet2 called on this form submit. servlet2 need to know the data entered within the field in the dialog. When i get it using
String data = request.getParameter(fieldname);
The data variable has a rabbish letters!!!!
Am sure that the charset for servlet1,servlet2 and the dialog is windows-1256 which is the charset used for both english/arabic.
Notes:
1- If the data that entered was in english, no roblem    
occurs and the parameter value has the correct letters same as the ones entered in the dialog.
2- If the data that entered was a mix of arabic and english letters, the letters in english will be read correctly within servlet2 but the arabic letters      
no.(rabbish).
I dont know how to solve this and what is causing this????
I need to get the correct value of the letters...
Any comment will be very helpful.
Thanx in advance....
samjav
samjavAsked:
Who is Participating?
 
girionisConnect With a Mentor Commented:
 Well I just tried a very simple and primitive example and guess what... It works fine for me

HTML

<html>
     <body>
          <form action="readArabic.jsp" name="testArabic" method="post">
               <input type="text" value="" name="arabic"/>
               <input type="submit" value="Go"/>
          </form>
     </body>
</html>

JSP

<html>
     <body>
          <%=request.getParameter("arabic")%>
     </body>
</html>

  I have set the encoding to be Arabic ISO-8859-6 in both the HTML and in the JSP page. I am using Opera 6.1 under Windows NT. When I go home I can try it under Linux as well... I have also tried it on Netscape 6.2.3 and it also works fine.
0
 
girionisCommented:
 What do you mean by saying rubbish? Do you actually see squares or ? instead of the letters or you see unrecognized letters? If the latter is the problem then it is definetely encoding problem and setting your browser's encoding to arabic would help (or try it with different encodings and see which one fits your needs betetr). If you see blank squares or ? instead of letters then I have a workaround for this. Let me know and I will post the code for you.

  Hope it helps.
0
 
samjavAuthor Commented:
When i enter ÇÓÊÚáÇã which means "query" the paremeter value is  Ø§Ø³ØªØ¹Ù„اÙ
when i enter ÊÌÑÈÉ which means "test" the paremeter value is تجربة
What do think girionis ?
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
samjavAuthor Commented:
It seems that this site didnt accept arabic letters, i dont know how to post the letters i got????
They are an arabic letter and ? series.
0
 
girionisCommented:
 I can see them properly. Just change the encoding from your browser. If you use IE do View... Encoding... Arabic. If you use Opera do View... Encoding... Arabic as well. If you are using Netscape do View... Character Encoding... Arabic

  Hope it helps.
0
 
samjavAuthor Commented:
I checked that, and the encoding already setted to Arabic???
0
 
samjavAuthor Commented:
Am using IE version 6.0
0
 
girionisCommented:
 Hmmm... Try adding the following method in one of your programmes:

private StringBuffer entitizeCharacters(String sections)
{
     char [] characters = sections.toCharArray();     // Create a character array.
     int arrayLength = characters.length;
     StringBuffer chars = new StringBuffer();          // will hold all the characters one by one.
     for (int i=0; i<arrayLength; i++)                    // Go through all the characters of the array.
     {
          // This is done in order to avoid the ArrayIndexOutOfBoundsException
          if (i == arrayLength)
               break;

          if ( (128 <= (int) characters[i] && (int) characters[i] <= 160) || ((int) characters[i]) >= 256 )
               chars.append("&#" + (int) characters[i] + ";");
          else
               chars.append(characters[i]);
     }

     return chars;
}          // end entitizeCharacters

  and then do:

String data = request.getParameter(fieldname);
StringBuffer sb = entitizeCharacters(data);
data = sb.toString();

  Tell us if this is working.
0
 
samjavAuthor Commented:
I dont know girionis, it seems that there is something wronge in my code....
It didn't work as expected....
Anyway, Thank you for your help ;(
samjav
0
 
laaxCommented:
Try this.
new String(request.getParameter(<FiledName>).getBytes("8859_1"));

Instead of "8859_1" Use your appropriate encoding.

[FYI, I use this for Japanese language.
new String(request.getParameter("Sortid").getBytes("8859_1"),"JISAutoDetect"));
]

Laax.

0
 
samjavAuthor Commented:
Hi Laax...
but how can i get my own encoding?
and what do you mean by JISAutoDetect?

0
 
laaxConnect With a Mentor Commented:
Use "8859_6" for Arabic....
[Latin/Arabic Alphabet, ISO 8859-6]

Please have a look at http://ietf.org/rfc/rfc2278.txt
for information.
0
 
samjavAuthor Commented:
I used it and it converts the letters returned from the parameter as ????????
I tried the entitizeCharacters method posted by girionis above, i call it after getting the parameter as you said:
String data = new String(request.getParameter(fieldName).getBytes("8859_6"));
StringBuffer sb = entitizeCharacters(data);
data = sb.toString();
But, the data string is still ?????????
I dont know what to do ;(?
Anyway, Thank you laax for your help and if you have another comments i will be very thankful...
samjav.

 
0
 
girionisCommented:
No comment has been added lately, so it's time to clean up this TA.

I will leave a recommendation in the Cleanup topic area that this question is:

- split points between laax and girionis

Please leave any comments here within the
next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER !

girionis
Cleanup Volunteer
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.