code: public void sendError(int code, String message)
     {
        FacesContext facesContext = FacesContext.getCurrentInstance();
        Assert.notNull(facesContext, "FacesContext argument was null.");
  
        Object response = facesContext.getExternalContext().getResponse();
        if (response instanceof HttpServletResponse)
        {
           sendError(code, message, (HttpServletResponse) response);
           facesContext.responseComplete();
        }
  
     }
docs: <p>
  Sends an error response to the client using the specified HTTP status
  code.
  </p>
  <p>
  Please note that this method can only be called from within the JSF
  lifecycle as it needs the {@link FacesContext} to obtain the
  {@link HttpServletResponse}. Please use
  {@link #sendError(int, String, HttpServletResponse)} in all other
  cases.
  </p>
  
  @param code the error status code
  @param message the descriptive message
  @see HttpServletResponse#sendError(int, String)