• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Encoding and Decoding

 
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I would also use an alert to see exactly what was returned from the escape function:
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic