• 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

decodeURI in javascript not working

 
Ranch Hand
Posts: 299
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i am facing issues with displaying data in JSPs. In my javascript code i try to decode the value so that it can be displayed in jsp correctly.Let me take an eg here,

say in DB value is stored as

Doctor's



When this value comes to javascript ,it is encoded.






please let me know what is the issue.I tried with unescape also. Also,there are no errors on the page
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm not sure what you expected to happen there, but "Doctor's" isn't in URL-encoded form so decoding it doesn't make any difference. Were you perhaps thinking of HTML escaping? It looks like it might be, although the forum software has hidden your attempt to say so, if that was the case.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are you confusing encode with decode?
 
Maan Suraj
Ranch Hand
Posts: 299
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
sorry for late reply, but actually i got confused between encode and decode characters.It is clear up to some extent now. But need more clarity on differences between HTML escaping and URL Encoding(if there is any). I mean some egamples will help.
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
HTML escaping is used to prevent characters such as < and > from being confused with markup. It is accomplished by using HTML entities such as &lt; and &gt; to represent the characters. This is used within the HTML page.

URL encoding allows representing characters that would otherwise be used as delimiters to be used in values. For example the &, =, and ? characters. They are encoded with special characters (such as + for space) or the hex value after the % sign.
 
Maan Suraj
Ranch Hand
Posts: 299
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
how do we handle these characters dynamically. Say you get these values from some other source like DB etc. Also,which character set does JSP use by default? What if i use UTF-8 charset in JSPs?
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Character set has nothing at all to do with any of this.

 
Maan Suraj
Ranch Hand
Posts: 299
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
could you please elaborate
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What's to elaborate? The character set being used has nothing at all to do with URI encoding or HTML escaping.

Not to go off into a different swamp, but you should always put:
as the first element in the <head> section and use UTF-8.
 
Maan Suraj
Ranch Hand
Posts: 299
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ok Thanks
 
reply
    Bookmark Topic Watch Topic
  • New Topic