code: public static HttpServletResponse getHttpServletResponse(ExternalContext ec)
      {
          if (isHttpServletRequest(ec))
          {
              return (HttpServletResponse) ec.getResponse();
          }
  
          return null;
      }
docs: Returns an HttpServletResponse if one exists on the externalContext or null
  if it does not.  Please note that some portal environments implement the
  PortletRequest and Response objects as HttpServletRequest/Response objects.
  This method handles these types of requests properly and will therefore
  return null in portal environments.
  
  @param response
  @return an HttpServletResponse if we have one or null if we do not
  @since 4.0