You need to URL-encode it. In plain Java, that would be
String encodedValue2 = URLEncoder.encode(value2, "UTF-8");
The &
should this way become %26
. The charset should be the same as the server is been configured to use to decode the incoming HTTP request URI (which often defaults to ISO-8859-1 though).
The JSF <f:param>
also does that when used in <h:outputLink>
and <h:link>
, however they aren't helpful in generating URLs for window.open()
, so you'd really need to perform this in backing bean with help of URLEncoder
or create a custom EL function. If you happen to use the JSF utility library OmniFaces, then you could use #{of:encodeURL()}
for that.