title: how to use policy of owasp-java-html-sanitizer on a jsp page
body: <p>I have been given a task to prevent our website from Cross-site Scripting (XSS).  The concept is new to me and I googled a lot and got owasp-java-html-sanitizer.  I created my own policy with </p>
  
  <pre><code>public static final PolicyFactory POLICY_DEFINITION = new HtmlPolicyBuilder()
  </code></pre>
  
  <p>by using <code>.allowAttributes</code> , I designed it .
  But now I am clueless how to use it ...I found following code snippet:</p>
  
  <pre><code>System.err.println("[Reading from STDIN]");
      // Fetch the HTML to sanitize.
      String html = CharStreams.toString(new InputStreamReader(System.in,
              Charsets.UTF_8));
      // Set up an output channel to receive the sanitized HTML.
      HtmlStreamRenderer renderer = HtmlStreamRenderer.create(System.out,
      // Receives notifications on a failure to write to the output.
              new Handler&lt;IOException&gt;() {
                  public void handle(IOException ex) {
                      Throwables.propagate(ex); // System.out suppresses
                                                  // IOExceptions
                  }
              },
              // Our HTML parser is very lenient, but this receives
              // notifications on
              // truly bizarre inputs.
              new Handler&lt;String&gt;() {
                  public void handle(String x) {
                      throw new AssertionError(x);
                  }
              });
      // Use the policy defined above to sanitize the HTML.
      HtmlSanitizer.sanitize(html, POLICY_DEFINITION.apply(renderer));
  }
  </code></pre>
  
  <p>but how can I apply this to my JSP because I think this is for simple HTML.
  Please help.</p>