aspose file tools*
The moose likes Beginning Java and the fly likes Encoding of special characters in the request parameter Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Encoding of special characters in the request parameter" Watch "Encoding of special characters in the request parameter" New topic
Author

Encoding of special characters in the request parameter

Ray Cutler
Greenhorn

Joined: Nov 04, 2004
Posts: 1
Let me explain the problem by giving an example.

In a form, I have a text field, First Name. I enter a value ��������. I submit the form. Upon the submit, the special characters in the first name is encoded to some weird value in the request parameter. This weird value is inserted in the database column. These encoded characters occupy more characters per normal character. So while inserting into the database,it exceeds the database column limit and it throws an exception.

How do I prevent this encoding of special characters in the Request parameter?
Francis Siu
Ranch Hand

Joined: Jan 04, 2003
Posts: 867
hi Ray Cutler
Um....If I do the encoding, first of all, I check the ASCII value for each character as the ASCII value may be out of the range. I am not sure that I answer your question but my idea is check the ASCII value for each value first and using (MOD) function to avoid some problem and then decide which Linear equation to encode the string. May be you can check which range of character using much byte to store, as I do not know the size of storing each character.
Just my suggestion and my simple idea


Francis Siu
SCJP, MCDBA
Petr Blahos
Ranch Hand

Joined: Apr 28, 2004
Posts: 131
Hi Ray,

Let me guess: You are talking about http client (like mozilla) on one
side and a servlet on the other side? Correct?

Firstly you must realize that it is not the servlet who encodes anything.
It is the web browser. You cannot prevent it. I would suggest that you
find out what kind of encoding it is (standard), what the character
encoding in the browser is (one of the headers). Then you can do it.

Look up HTTP RFC and have a nice evening ;-)

Petr


Get a better web browser:<br /><a href="http://www.mozilla.org/products/firefox/switch.html" target="_blank" rel="nofollow">http://www.mozilla.org/products/firefox/switch.html</a>
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Encoding of special characters in the request parameter