Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

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

Posted on 2002-07-15
14
335 Views
Last Modified: 2013-11-24
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
0
Comment
Question by:samjav
  • 7
  • 5
  • 2
14 Comments
 
LVL 35

Expert Comment

by:girionis
ID: 7154273
 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
 

Author Comment

by:samjav
ID: 7154322
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
 

Author Comment

by:samjav
ID: 7154332
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
Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

 
LVL 35

Expert Comment

by:girionis
ID: 7154368
 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
 

Author Comment

by:samjav
ID: 7154394
I checked that, and the encoding already setted to Arabic???
0
 

Author Comment

by:samjav
ID: 7154397
Am using IE version 6.0
0
 
LVL 35

Expert Comment

by:girionis
ID: 7154444
 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
 

Author Comment

by:samjav
ID: 7156656
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
 
LVL 1

Expert Comment

by:laax
ID: 7159006
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
 

Author Comment

by:samjav
ID: 7159022
Hi Laax...
but how can i get my own encoding?
and what do you mean by JISAutoDetect?

0
 
LVL 1

Assisted Solution

by:laax
laax earned 25 total points
ID: 7159176
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
 

Author Comment

by:samjav
ID: 7159282
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
 
LVL 35

Accepted Solution

by:
girionis earned 25 total points
ID: 7159346
 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
 
LVL 35

Expert Comment

by:girionis
ID: 8917372
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

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

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

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
how to see all occupied ports on windows 10 laptop 15 75
How  can  i  resolve  HTTP Status 404 -? 8 42
ejb mdb examples 1 6
ejb entity bean example issue 2 16
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question