1

In my code I have a scriptlet that sets the href equal to a value that may contain spaces.

Here is an example:

<a data-toggle="collapse" href="#<%=supportGroup%>">Support group: <%=supportGroup%></a>

The value of supportGroup is something like ENT-ESD VALUE. This value is an id to a div as well. I am wondering of a way to encode this value. Any suggestions?

Albert P
  • 41
  • 1
  • 5

1 Answers1

0

If you use JSP you can use JSTL.

<c:url value="https://www.google.com/" var="url" />

<a href="${url}">Link</a>

Result:

<a href="https://www.google.com/">Link</a>

or

<c:url value="https://www.google.com/" var="url">
     <c:param name="q" value="anything" />
</c:url>

<a href="${url}">Link</a>

Result:

<a href="https://www.google.com/?q=anything">Link</a>
codeaholicguy
  • 1,671
  • 1
  • 11
  • 18