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);

3
  • 3
    Not sure what this has to do with java.nio.file or why you consider this to be "hacking". Commented Jan 20, 2016 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 : docs.oracle.com/javase/8/docs/api/java/util/StringJoiner.html Commented Jan 20, 2016 at 21:56
  • 1
    Or String.join : docs.oracle.com/javase/8/docs/api/java/lang/… Commented Jan 20, 2016 at 21:57

1 Answer 1

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?

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.