}
    public void sendError(int code, String message) throws IOException    {        if (isCommitted())            Log.warn("Committed before "+code+" "+message);        reset();        message=message==null?HttpGenerator.getReason(code):message;        setStatus(code,message);        // If we are allowed to have a body        if (code!=SC_NO_CONTENT &&            code!=SC_NOT_MODIFIED &&            code!=SC_PARTIAL_CONTENT &&            code>=SC_OK)        {            Request request = _connection.getRequest();            // TODO - probably should reset these after the request?            request.setAttribute(ServletHandler.__J_S_ERROR_STATUS_CODE,new Integer(code));            request.setAttribute(ServletHandler.__J_S_ERROR_MESSAGE, message);            request.setAttribute(ServletHandler.__J_S_ERROR_REQUEST_URI, request.getRequestURI());            request.setAttribute(ServletHandler.__J_S_ERROR_SERVLET_NAME,request.getServletName());             ErrorHandler error_handler = null;            ContextHandler.Context context = request.getContext();            if (context!=null)                error_handler=context.getContextHandler().getErrorHandler();            if (error_handler!=null)                error_handler.handle(null,_connection.getRequest(),this, Handler.ERROR);            else            {                setContentType(MimeTypes.TEXT_HTML);                ByteArrayISO8859Writer writer= new ByteArrayISO8859Writer(2048);                HttpConnection connection = HttpConnection.getCurrentConnection();                ErrorHandler.writeErrorPage(request, writer, connection.getResponse().getStatus(), connection.getResponse().getReason());                writer.flush();                setContentLength(writer.size());                writer.writeTo(getOutputStream());                writer.destroy();            }        }        else if (code!=SC_PARTIAL_CONTENT)        {            _connection.getRequestFields().remove(HttpHeaders.CONTENT_TYPE_BUFFER);            _connection.getRequestFields().remove(HttpHeaders.CONTENT_LENGTH_BUFFER);            _characterEncoding=null;            _mimeType=null;            _cachedMimeType=null;        }        complete();    }