File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » Java » Servlets
Bookmark "URL Encode" Watch "URL Encode" New topic

URL Encode

ford Darcy Jr
Ranch Hand

Joined: Jan 26, 2005
Posts: 76

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 ?

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

Joined: Jan 10, 2002
Posts: 63858

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

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

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

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.

I agree. Here's the link:
subject: URL Encode
It's not a secret anymore!