I have a JSP page with a scriptlet of the form
<%
String imageId = request.getParameter("imageId");
if(getImageById == null){
throw new JspException("No data found for " + imageId);
}
%>
When the exception is thrown, the request parameter "imageId" is printed, allowing an XSS attack.
What's the best way to sanitize the input to Exception() to prevent this?