Win a copy of Machine Learning for Business: Using Amazon SageMaker and JupyterE this week in the Jython/Python forum
or Object Design Style Guide in the Object-Oriented programming forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
  • Knute Snortum
Sheriffs:
  • Liutauras Vilda
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Joe Ess
  • salvin francis
  • fred rosenberger

special character for space in URL

 
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I know we can use %20 to replace any space character. For example,

http://myserver/myaction?param1=abc%20def¶m2=xyz

But when I use URLEncoder.encode API to encode the parameter values I find it converts space character into "+" instead of %20. When I use "+" to replace the %20 in URL it also works.

So is it true that both "+" and "%20" can be used to replace space char in URL ?
 
Marshal
Posts: 67343
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes.
 
Ranch Hand
Posts: 1512
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The MIME type of the data being encoded plays a role. It may even be browser dependent - application/x-www-form-urlencoded uses + and properly encoded URIs use %20.
 
Bear Bibeault
Marshal
Posts: 67343
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is nothing improper about using + to encode spaces in URLs.
 
Ranch Hand
Posts: 67
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've never seen + used in place of %20 in a URL. Decided that since I spent a few minutes thinking on this one to share the references.

RFC 2396: http://www.ietf.org/rfc/rfc2396.txt, sections 2.2 and 3.4.

I visualize URI = URL + URN. I think of the query string as a kind of extension to the URI and not part of my HTTP request, the URN located at URL.

A Google of this topic got several hits to the effect that %20 is interchangeable with + in a URL. They all have a similar example URL.

I finally found this: http://www.w3.org/Addressing/URL/4_URI_Recommentations.html, the section Query strings.

This method was used to make query URIs easier to pass in systems which did not allow spaces.


 
What? What, what, what? What what tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!