Help coderanch get a
new server
by contributing to the fundraiser
  • 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
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

How to replace space in URL String

 
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi i have a very difficult problem, that must be overcome. i am using a midlet to send a query to a servlet using HTTPConnection class's method open. The query is like this

connection.open("http://localhost:8080?PathProject/ps/query=first loc");

this throws an error "Space in URL". so i replaced the space with %20.

connection.open("http://localhost:8080?PathProject/ps/query=first%20loc");

this works. The Conenction is wrapped in its own class. The constructor of the class recives a String url as a parameter. so i want to replace every occurance of a space in that string with %20. but it dosent allow me to use

url.replace(' ','%20');

please help me with this problem .thanks. note. in above first loc is the name of a location in my city. and this is then read from the database. how can i do this. replace spaces with %20. i carnt cahnge the complete database to remove space between areas.

[ September 17, 2005: Message edited by: Mateen Dar ]
[ September 17, 2005: Message edited by: Mark Spritzler ]
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Mateen,

Sorry, but I changed your topic title.

What usually happens here is that threads marked "urgent" tend not to get answered.

Mark
 
reply
    Bookmark Topic Watch Topic
  • New Topic