| Author |
decode the string server side which is received from the client side
|
Vas Miriyala
Ranch Hand
Joined: Sep 14, 2009
Posts: 114
|
|
Hi all,
I have used escape function in javascript to encode the user entered text and sending
this encoded string to the server side,Now i want to decode this encoded string in Server side to do the persistance operations.
any idea on this how can we do?
|
 |
Wendy Gibbons
Bartender
Joined: Oct 21, 2008
Posts: 1098
|
|
|
look into the java class URLEncoder
|
 |
Vas Miriyala
Ranch Hand
Joined: Sep 14, 2009
Posts: 114
|
|
Hi all
I solved the problem by using java.net.URLDecoder.decode("stringName","UTF-8"); in servlets
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56529
|
|
|
Why did you encode the string in the first place?
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
Wendy Gibbons
Bartender
Joined: Oct 21, 2008
Posts: 1098
|
|
Bear Bibeault wrote:Why did you encode the string in the first place?
isn't it sensible to do that for user entered text, just in case they do something crazy?
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56529
|
|
Wendy Gibbons wrote:
Bear Bibeault wrote:Why did you encode the string in the first place?
isn't it sensible to do that for user entered text, just in case they do something crazy?
Such as?
The text is going to be encoded automatically for delivery to the server, and automatically decoded. Why doubly-encode it, necessitating decoding on the server? It's just an extra step that does absolutely nothing constructive.
|
 |
Wendy Gibbons
Bartender
Joined: Oct 21, 2008
Posts: 1098
|
|
Bear Bibeault wrote:
Wendy Gibbons wrote:
Bear Bibeault wrote:Why did you encode the string in the first place?
isn't it sensible to do that for user entered text, just in case they do something crazy?
Such as?
The text is going to be encoded automatically for delivery to the server, and automatically decoded. Why doubly-encode it, necessitating decoding on the server? It's just an extra step that does absolutely nothing constructive.
oh ok
|
 |
 |
|
|
subject: decode the string server side which is received from the client side
|
|
|