code: public static void sendError( String messageKey, Object[] messageArgs, ServletRequest request,
                                    ServletResponse response, Throwable cause, boolean avoidDirectResponseOutput )
              throws IOException
      {
          assert messageArgs.length == 0 || ! ( messageArgs[0] instanceof Object[] )
                  : "Object[] passed to sendError; this is probably a mistaken use of varargs";
  
          // request may be null because of deprecated FlowController.sendError().
          if ( request != null && avoidDirectResponseOutput )
          {
              String baseMessage = Bundle.getString( messageKey + "_Message", messageArgs );
              throw new ResponseOutputException( baseMessage, cause );
          }
  
          // Filter the message args to prevent cross-site scripting (XSS) attacks (e.g., if one of the args is something
          // that ultimately came from the user request, and it contains something like <script>[some sscript]</script>.
          for (int i = 0; i < messageArgs.length; i++) {
              Object messageArg = messageArgs[i];
              messageArgs[i] = messageArg != null ? filterValue(messageArg.toString()) : null;
          }
          
          String html = Bundle.getString( messageKey + "_Page", messageArgs );
          response.setContentType( "text/html;charset=UTF-8" );
          response.getWriter().println(html);
          ServletUtils.preventCache( response );
      }
docs: Write an error to the response.