Alister Ernest
Alister Ernest

Reputation: 35

Adding the value from <c:param> to the end of the url

I have a jsp that generates a URL. Sample below:

<c:url var="url" value="https://${myHost}/${myEncodedString}">
  <c:param name="code" value="123"/>
</c:url>

The result of this looks like https://www.test.com/?code=123&myEncodedString

I want to make it look like https://www.test.com/?myEncodedString&code=123

How do I re-arrange or re-order parameters being set on the URL by the <c:param>

Upvotes: 0

Views: 36

Answers (1)

Yang Daniel
Yang Daniel

Reputation: 135

<c:url var="url" value="https://${myHost}/?${myEncodedString}">
  <c:param name="code" value="123"/>
</c:url>

According to you result, there should be a "?" before ${myEncodedString}

If you want to re-arrange param, I suggest do it in following.

<c:url var="url" value="https://${myHost}/?">
  <c:param name="myEncodedString"/>
  <c:param name="code" value="123"/>
</c:url>

the ouput

    https://www.test.com/?myEncodedString=&code=123

I believe this is url is equal to

    https://www.test.com/?myEncodedString&code=123

Upvotes: 1

Related Questions