This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Servlets and the fly likes URL Encode Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "URL Encode" Watch "URL Encode" New topic
Author

URL Encode

ford Darcy Jr
Ranch Hand

Joined: Jan 26, 2005
Posts: 76
Hi,

Is there any option for specifying the encoding string in URL encode. I am using: file = URLEncoder.encode(file) then if file contains any spaces its being replaced with +. But I need spaces to be replaced with %20. Is there anyway to specify the encoding string in URLEncode ?

Thanks.
Jack Daniel
Ranch Hand

Joined: Jun 15, 2002
Posts: 163
ok, I too have a question regarding this..

In the query string, i know you cannot have space for parameters passed..

now coming to encoding url.. some use '+' for space and some use %20.
what is the difference ?? and which one is the preferred one???

I think google uses '+' , so i use '+'
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60810
    
  65

The '%' encoding can be used for any arbitrary character while + specifically repersents the space character.

I use whatever java.net.URLEncoder produces. Why would you do this 'by hand'?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

"Jack Daniel",
You have changed your display name from one which was valid to one which is not. Accounts with invalid display names get deleted.

Please change it back immediately.

thanks,
Dave.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: URL Encode
 
Similar Threads
File access : blanks in file name
URLEncoder question
Using UTF-8 encoding for jsp textarea field instead HTML encoding
Problem with URLEncoding
Problem regarding reading a String