aspose file tools
The moose likes Servlets and the fly likes decode the string server side which is received from the client side Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Servlets
Reply Bookmark "decode the string server side which is received from the client side" Watch "decode the string server side which is received from the client side" New topic
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
    
  14

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
    
  14

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
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: decode the string server side which is received from the client side
 
Similar Threads
XML Escape Newline Characters
How to pass characters like+ as parameter in the URL
August Newsletter Puzzle
about URLEncoding
URLEncoder & URLDecoder