• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to pass a path to URL?

 
Bartender
Posts: 1971
17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am trying to create a web service method that returns the file size of a passed file path.

The problem is that passing the path with multiple "/" (paths) is being misinterpreted as multiple GET parameters rather than a single (path) parameter.

The calling program is dynamically generating the path, but the passed paths will be something like /Users/Mike/Desktop/...../FileName.jpg

Is there any way to send a path like that as one parameter?

TIA

- mike
 
Mike London
Bartender
Posts: 1971
17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Mike London wrote:I am trying to create a web service method that returns the file size of a passed file path.

The problem is that passing the path with multiple "/" (paths) is being misinterpreted as multiple GET parameters rather than a single (path) parameter.

The calling program is dynamically generating the path, but the passed paths will be something like /Users/Mike/Desktop/...../FileName.jpg

Is there any way to send a path like that as one parameter?

TIA

- mike




** SOLVED **

Solution turned out to be to use "%2F".

- mike
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In other words, you needed to URL-encode the path so that it would act as a single parameter. Perhaps you just wrote code which would change "/" to "%2F"? If so, you might consider using Java's built-in URLEncoder class, which will take care of that and of any other edge cases you haven't encountered yet.
 
Mike London
Bartender
Posts: 1971
17
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Paul Clapham wrote:In other words, you needed to URL-encode the path so that it would act as a single parameter. Perhaps you just wrote code which would change "/" to "%2F"? If so, you might consider using Java's built-in URLEncoder class, which will take care of that and of any other edge cases you haven't encountered yet.



Yep, you got it. BTW, the URLEncode idea was awesome! I had not thought of that and it will save me many hours of frustration. Thank you!!!

-------

URLEncode like the one below that I saw, here: http://alvinalexander.com/blog/post/java/how-encode-java-string-send-web-server-safe-url



(it works without the array and the for loop, too.)

// output --> 'localhost%3A4567%2Ftest%2Ffor%2Fme%2Fthis%2Furlencode'
------------
Thanks for the cow! :)

- mike
 
reply
    Bookmark Topic Watch Topic
  • New Topic