File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java Micro Edition and the fly likes How to replace space in URL String Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Mobile » Java Micro Edition
Bookmark "How to replace space in URL String" Watch "How to replace space in URL String" New topic
Author

How to replace space in URL String

Mateen Dar
Ranch Hand

Joined: Jan 14, 2005
Posts: 55
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 ]
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

Hi Mateen,

Sorry, but I changed your topic title.

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

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to replace space in URL String
 
Similar Threads
How can i change the url of struts?
redirection problem
getting set up apache/tomcat
Problem with redirect and a parameter
How to use IN OUT parameter