This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
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

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

Encoding of special characters in the request parameter

Ray Cutler

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
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 ;-)


Get a better web browser:<br /><a href="" target="_blank" rel="nofollow"></a>
I agree. Here's the link:
subject: Encoding of special characters in the request parameter
It's not a secret anymore!