0

I need to construct a relative path from incoming query string parameters from the front-end. Then I need to append it to the service URL like this:

Front end executes:

Http://backendhost.com?param_one=abd&param_two=cba

The back-end gets both parameters and needs to execute

https://secure.remote.service/abd/cba

What I have right now on the back-end is this:

https://secure.remote.service
abd
cba

I would like to use a some native library to do this without hacking away using the form

"/" + param1 + "/" param2
  • This needs to be created and passed to a function that later will extract the back-end secure URL. So not this:

    new URL(url, relativePath);

Dannyvas
  • 101
  • 3
  • 11
  • 3
    Not sure what this has to do with `java.nio.file` or why you consider this to be "hacking". – RealSkeptic Jan 20 '16 at 21:52
  • 1
    Please clarify, why can you not use java.nio? Also what is hacky about concatenation? That is what it is for. If you insist on doing something different and are using Java 8 look at : https://docs.oracle.com/javase/8/docs/api/java/util/StringJoiner.html – mascoj Jan 20 '16 at 21:56
  • 1
    Or String.join : https://docs.oracle.com/javase/8/docs/api/java/lang/String.html#join-java.lang.CharSequence-java.lang.CharSequence...- – mascoj Jan 20 '16 at 21:57

1 Answers1

1

Why not to use an UriBuilder? it was already discussed here:

What is the idiomatic way to compose a URL or URI in Java? and here:

Is there a right way to build a URL?

Community
  • 1
  • 1