• 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

url encoding

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,
please explain me what exactly is urlencoding ? when is necessacry ?for ex.
url is http://www.xyz.com/abc/servlet1
with this i want to pass two paramters
bkid whose value is in a variable bkid1
title whose value is in title1
the usual way is
http://www.xyz.com/abc/servlet1?bkid=bkid1&title=title1
how to encode this url ?

any help is appreciated
thank you
sridevi
 
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When sending data by a browser (through query string) it is encoded. Here is what encodeing will do:
The ASCII characters 'a' through 'z', 'A' through 'Z', '0' through '9', and ".", "-", "*", "_" remain the same.
The space character ' ' is converted into a plus sign '+'.
All other characters are converted into the 3-character string "%xy", where xy is the two-digit hexadecimal
representation of the lower 8-bits of the character.
I beleive to encode your URL you should do something akin to (if both title1 & bkid1 are vars):
String String = "http://www.xyz.com/abc/servlet1?bkid=" + URLEncoder.encode(bkid1) + "&title="+ URLEncoder.encode(title1)
hope this helps
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic