Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Encoding and Decoding

 
francis varkey
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Respected Sirs,
In my application I have using an ajax. In url I am passing some values containg "&" .So I am encoding it using 'escape()' function of javascript.
Later in Servlet I am decoding it using "java.net.URLDecoder.decode(String,"UTF-8")". But this decode() method is not working.

Regards Francis
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by francis varkey:
But this decode() method is not working.


That doesn't give us a whole lot to work with.
What string are you decoding?
What is being returned from the decode method?
What were you expecting it to return?

The more specific you can make your question, the easier it will be for us to answer.
 
francis varkey
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Client side code --- javascript
--------------------------------------

Here I am encoding "srcName" using escape() function.
----------------------------------------------------------------------

Server side code ---Java
----------------------------
I am expecting the out put is Test & Test
But I get
Test & Test
That is decoding is not done.


[BSouther: Added UBB CODE tags]
[ September 08, 2007: Message edited by: Ben Souther ]
 
francis varkey
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the above two posts ,the last line is

I am expecting the out put is Test & Test
But I get
Test & amp; Test (here I put a space after & )
That is decoding is not done.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I were debugging this, the first thing I would do is add a print statement before decoding on the Java side to see exactly what I'm decoding.

 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would also use an alert to see exactly what was returned from the escape function:
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic