The JSP parser handles HTML comments as template text. It doesn't ignore its contents. The HTML comments are only ignored by HTML parsers/interpreters (webbrowsers!). You should use JSP comments instead to prevent the JSP parser from processing the particular piece of code.
<%-- <%=paramName%>=<%=request.getParameter(paramName)%><BR> --%>
Note the <%-- --%>
style as opposed to <!-- -->
HTML comment style. The JSP parser won't parse them, but it removes them from the output. Thus you won't see them in the generated HTML output.
The XSS risk is here because you're not escaping user-controlled input here. Request parameters are fully controllable by endsers. The enduser may for instance pass --><script>alert('xss')</script><!--
as parameter value and it would get executed. This puts the doors wide open for XSS and CSRF attacks. The malicious script may for example send all cookies by an ajax request to a malicious server. The attacker can then just copy the cookie value to be able to be logged in as yourself.
You should use JSTL c:out
tag or fn:escapeXml
function to escape user-controlled input. I've answered this in detail several times before, under each here. More explanation about CSRF can be found in my answer here.