Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

decode the string server side which is received from the client side

 
Vas Miriyala
Ranch Hand
Posts: 114
Hibernate Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1110
Eclipse IDE Oracle VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
look into the java class URLEncoder
 
Vas Miriyala
Ranch Hand
Posts: 114
Hibernate Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all
I solved the problem by using java.net.URLDecoder.decode("stringName","UTF-8"); in servlets
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64629
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why did you encode the string in the first place?
 
Wendy Gibbons
Bartender
Posts: 1110
Eclipse IDE Oracle VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64629
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1110
Eclipse IDE Oracle VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic