| Author |
Encoding and Decoding
|
francis varkey
Ranch Hand
Joined: Sep 13, 2005
Posts: 155
|
|
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
Joined: Dec 11, 2004
Posts: 13410
|
|
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.
|
Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
|
 |
francis varkey
Ranch Hand
Joined: Sep 13, 2005
Posts: 155
|
|
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
Joined: Sep 13, 2005
Posts: 155
|
|
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
Joined: Dec 11, 2004
Posts: 13410
|
|
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
Joined: Dec 11, 2004
Posts: 13410
|
|
I would also use an alert to see exactly what was returned from the escape function:
|
 |
 |
|
|
subject: Encoding and Decoding
|
|
|