title: Protection against Cross site scripting on specific JSP and Servlet code
body: <p>Here are the servelet cum JSP code, let me know how we could protect them from XSS?</p>
  
  <p>Servlet Code:</p>
  
  <pre><code>String strRequestScrip = SecurityCheck.getStringParameter(request,PARAM_SCRIP_CODE);
  
   List arrScripLocator = MarketWatchUtils.getEqScripLocator(strRequestScrip, strExchangeCode, application);
  
   request.setAttribute("arrScripLocator", arrScripLocator);
  
   request.getRequestDispatcher("/ajax/ajaxScripLocator.jsp").forward(request, response);
  </code></pre>
  
  <p>Jsp Code:</p>
  
  <pre><code>final List arrScripLocator = (List) request.getAttribute("arrScripLocator");
  
  int intScripLocatorSize = arrScripLocator != null ? arrScripLocator.size() : 0;
  
  intScripLocatorSize = intScripLocatorSize &lt;= 20 ? intScripLocatorSize : 20;
  
  out.print(intScripLocatorSize);
  </code></pre>