response.setStatus(HttpServletResponse.SC_OK);
if (base_request.getConnection().getResponse().getStatus()<0) response.setStatus(HttpServletResponse.SC_OK);
    public void handle(String target, HttpServletRequest request,HttpServletResponse response, int type)         throws IOException    {        if (!isStarted())            return;        // Get the base requests        final Request base_request=(request instanceof Request)?((Request)request):HttpConnection.getCurrentConnection().getRequest();        final String old_servlet_name=base_request.getServletName();        final String old_servlet_path=base_request.getServletPath();        final String old_path_info=base_request.getPathInfo();                try        {            ServletHolder servlet_holder=null;            FilterChain chain=null;                        // find the servlet            if (target.startsWith("/"))            {                // Look for the servlet by path                PathMap.Entry entry=getHolderEntry(target);                if (entry!=null)                {                    servlet_holder=(ServletHolder)entry.getValue();                    base_request.setServletName(servlet_holder.getName());                    if(Log.isDebugEnabled())Log.debug("servlet="+servlet_holder);                                        String servlet_path_spec=(String)entry.getKey();                     String servlet_path=entry.getMapped()!=null?entry.getMapped():PathMap.pathMatch(servlet_path_spec,target);                    String path_info=PathMap.pathInfo(servlet_path_spec,target);                                        if (type==INCLUDE)                    {                        base_request.setAttribute(Dispatcher.__INCLUDE_SERVLET_PATH,servlet_path);                        base_request.setAttribute(Dispatcher.__INCLUDE_PATH_INFO, path_info);                    }                    else                    {                        base_request.setServletPath(servlet_path);                        base_request.setPathInfo(path_info);                    }                                        if (servlet_holder!=null && _filterMappings!=null && _filterMappings.length>0)                        chain=getFilterChain(type, target, servlet_holder);                }                  }            else            {                // look for a servlet by name!                servlet_holder=(ServletHolder)_servletNameMap.get(target);                if (servlet_holder!=null && _filterMappings!=null && _filterMappings.length>0)                {                    base_request.setServletName(servlet_holder.getName());                    chain=getFilterChain(type, null,servlet_holder);                }            }            if (Log.isDebugEnabled())             {                Log.debug("chain="+chain);                Log.debug("servelet holder="+servlet_holder);            }            // Do the filter/handling thang            if (servlet_holder!=null)            {                response.setStatus(HttpServletResponse.SC_OK);  // Must be handled.                if (chain!=null)                    chain.doFilter(request, response);                else                     servlet_holder.handle(request,response);            }            else                notFound(request, response);        }        catch(RetryRequest e)        {            throw e;        }        catch(EofException e)        {            throw e;        }        catch(Exception e)        {            Throwable th=e;            while (th instanceof ServletException)            {                Log.warn(th);                Throwable cause=((ServletException)th).getRootCause();                if (cause==th || cause==null)                    break;                th=cause;            }                        if (th instanceof HttpException)                throw (HttpException)th;            else if (Log.isDebugEnabled() || !( th instanceof java.io.IOException))            {                Log.warn(request.getRequestURI()+": ",th);                if(Log.isDebugEnabled())                    Log.debug(request.toString());               }            // TODO clean up            Log.warn(request.getRequestURI(), th);                        // TODO httpResponse.getHttpConnection().forceClose();            if (!response.isCommitted())            {                request.setAttribute(ServletHandler.__J_S_ERROR_EXCEPTION_TYPE,th.getClass());                request.setAttribute(ServletHandler.__J_S_ERROR_EXCEPTION,th);                if (th instanceof UnavailableException)                {                    UnavailableException ue = (UnavailableException)th;                    if (ue.isPermanent())                        response.sendError(HttpServletResponse.SC_NOT_FOUND,th.getMessage());                    else                        response.sendError(HttpServletResponse.SC_SERVICE_UNAVAILABLE,th.getMessage());                }                else                    response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR,th.getMessage());            }            else                if(Log.isDebugEnabled())Log.debug("Response already committed for handling "+th);        }        catch(Error e)        {               Log.warn("Error for "+request.getRequestURI(),e);            if(Log.isDebugEnabled())Log.debug(request.toString());                        // TODO httpResponse.getHttpConnection().forceClose();            if (!response.isCommitted())            {                request.setAttribute(ServletHandler.__J_S_ERROR_EXCEPTION_TYPE,e.getClass());                request.setAttribute(ServletHandler.__J_S_ERROR_EXCEPTION,e);                response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR,e.getMessage());            }            else                if(Log.isDebugEnabled())Log.debug("Response already committed for handling ",e);        }        finally        {            base_request.setServletName(old_servlet_name);            if (type!=INCLUDE)            {                base_request.setServletPath(old_servlet_path);                base_request.setPathInfo(old_path_info);             }        }        return;    }