title: How to encode response to JSON in filter without failing XSS
body: <p>BELOW IS THE static code analysis report from SpotBugs</p>
  
  <p>XSS_SERVLET: Potential XSS in Servlet
  A potential XSS was found. It could be used to execute unwanted JavaScript in a client's browser. (See references)</p>
  
  <p>Vulnerable Code:</p>
  
  <pre><code>protected void doGet(HttpServletRequest req, HttpServletResponse resp) 
  throws ServletException, IOException {
  String input1 = req.getParameter("input1");
  [...]
  resp.getWriter().write(input1);
  }
  </code></pre>
  
  <p>Solution:</p>
  
  <pre><code>protected void doGet(HttpServletRequest req, HttpServletResponse resp)     throws ServletException, IOException {
      String input1 = req.getParameter("input1");
      [...]
      resp.getWriter().write(Encode.forHtml(input1))
  </code></pre>
  
  <p>Encode.forJava for JavaScript is writing special chars and JSON string is compromised.</p>
  
  <p>How to use Encoder to send JSON string. without failing security CHECK</p>