/* ------------------------------------------------------------ */
  public void sendError(int status, String message) throws IOException {
    // Find  error page.
    String error_page =
        _servletHttpRequest.getServletHandler().getErrorPage(status, _servletHttpRequest);

    resetBuffer();

    // Handle error page?
    if (error_page == null) {
      // handle normally
      _httpResponse.sendError(status, message);
    } else {
      _httpResponse.setStatus(status, message);

      if (message == null) {
        message = (String) HttpResponse.__statusMsg.get(TypeUtil.newInteger(status));
        if (message == null) message = "" + status;
      }

      // handle error page
      ServletHolder holder = _servletHttpRequest.getServletHolder();
      if (holder != null)
        _servletHttpRequest.setAttribute(ServletHandler.__J_S_ERROR_SERVLET_NAME, holder.getName());
      _servletHttpRequest.setAttribute(
          ServletHandler.__J_S_ERROR_REQUEST_URI, _servletHttpRequest.getRequestURI());
      _servletHttpRequest.setAttribute(ServletHandler.__J_S_ERROR_STATUS_CODE, new Integer(status));
      _servletHttpRequest.setAttribute(ServletHandler.__J_S_ERROR_MESSAGE, message);

      RequestDispatcher dispatcher =
          _servletHttpRequest
              .getServletHandler()
              .getServletContext()
              .getRequestDispatcher(error_page);

      try {
        ((Dispatcher) dispatcher).error(_servletHttpRequest, this);
      } catch (ServletException e) {
        log.warn(LogSupport.EXCEPTION, e);
        _httpResponse.sendError(status, message);
      }
    }
    complete();
  }
  /* ------------------------------------------------------------ */
  public void sendRedirect(String url) throws IOException {
    if (url == null) throw new IllegalArgumentException();

    if (!URI.hasScheme(url)) {
      StringBuffer buf = _servletHttpRequest.getHttpRequest().getRootURL();
      if (url.startsWith("/")) buf.append(URI.canonicalPath(url));
      else {
        String path = _servletHttpRequest.getRequestURI();
        String parent = (path.endsWith("/")) ? path : URI.parentPath(path);
        url = URI.canonicalPath(URI.addPaths(parent, url));
        if (!url.startsWith("/")) buf.append('/');
        buf.append(url);
      }

      url = buf.toString();
    }

    resetBuffer();

    _httpResponse.setField(HttpFields.__Location, url);
    _httpResponse.setStatus(HttpResponse.__302_Moved_Temporarily);
    complete();
  }