protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
    {
        String servletPath = (String) request.getAttribute(Dispatcher.__INCLUDE_SERVLET_PATH);
        String pathInfo = null;
        if (servletPath == null)
        {
            servletPath = request.getServletPath();
            pathInfo = request.getPathInfo();
        }
        else
            pathInfo = (String) request.getAttribute(Dispatcher.__INCLUDE_PATH_INFO);

        String pathInContext = URI.addPaths(servletPath, pathInfo);
                
        boolean endsWithSlash = pathInContext.endsWith("/");
        Resource resource = getResource(pathInContext);

        // Is the method allowed?
        String method = request.getMethod();
        if (_AllowString.indexOf(method) < 0)
        {
            if (resource != null && resource.exists())
            {
                response.setHeader(HttpFields.__Allow, _AllowString);
                response.sendError(HttpResponse.__405_Method_Not_Allowed);
            }
            else
                response.sendError(HttpResponse.__404_Not_Found);
            return;
        }

        // Handle the request
        try
        {
            // handle by method.
            if (method.equals(HttpRequest.__GET) || method.equals(HttpRequest.__POST) || method.equals(HttpRequest.__HEAD))
                handleGet(request, response, pathInContext, resource, endsWithSlash);
            else if (_putAllowed && method.equals(HttpRequest.__PUT))
                handlePut(request, response, pathInContext, resource);
            else if (_delAllowed && method.equals(HttpRequest.__DELETE))
                handleDelete(request, response, pathInContext, resource);
            else if (_putAllowed && _delAllowed && method.equals(HttpRequest.__MOVE))
                handleMove(request, response, pathInContext, resource);
            else if (method.equals(HttpRequest.__OPTIONS))
                handleOptions(request, response);
            else if (method.equals(HttpRequest.__TRACE))
                _servletHandler.handleTrace(request, response);
            else
            {
                // anything else...
                try
                {
                    if (resource.exists())
                        response.sendError(HttpResponse.__501_Not_Implemented);
                    else
                        _servletHandler.notFound(request, response);
                }
                catch (Exception e)
                {
                    LogSupport.ignore(log, e);
                }
            }
        }
        catch (IllegalArgumentException e)
        {
            LogSupport.ignore(log, e);
        }
        finally
        {
            if (resource != null && !(resource instanceof CachedResource))
                resource.release();
        }

    }
protected void service ( HttpServletRequest request , HttpServletResponse response ) throws ServletException , IOException { String servletPath = ( String ) request . getAttribute ( Dispatcher . __INCLUDE_SERVLET_PATH ) ; String pathInfo = null ; if ( servletPath == null ) { servletPath = request . getServletPath ( ) ; pathInfo = request . getPathInfo ( ) ; } else pathInfo = ( String ) request . getAttribute ( Dispatcher . __INCLUDE_PATH_INFO ) ; String pathInContext = URI . addPaths ( servletPath , pathInfo ) ; boolean endsWithSlash = pathInContext . endsWith ( "/" ) ; Resource resource = getResource ( pathInContext ) ; String method = request . getMethod ( ) ; if ( _AllowString . indexOf ( method ) < 0 ) { if ( resource != null && resource . exists ( ) ) { response . setHeader ( HttpFields . __Allow , _AllowString ) ; response . sendError ( HttpResponse . __405_Method_Not_Allowed ) ; } else response . sendError ( HttpResponse . __404_Not_Found ) ; return ; } try { if ( method . equals ( HttpRequest . __GET ) || method . equals ( HttpRequest . __POST ) || method . equals ( HttpRequest . __HEAD ) ) handleGet ( request , response , pathInContext , resource , endsWithSlash ) ; else if ( _putAllowed && method . equals ( HttpRequest . __PUT ) ) handlePut ( request , response , pathInContext , resource ) ; else if ( _delAllowed && method . equals ( HttpRequest . __DELETE ) ) handleDelete ( request , response , pathInContext , resource ) ; else if ( _putAllowed && _delAllowed && method . equals ( HttpRequest . __MOVE ) ) handleMove ( request , response , pathInContext , resource ) ; else if ( method . equals ( HttpRequest . __OPTIONS ) ) handleOptions ( request , response ) ; else if ( method . equals ( HttpRequest . __TRACE ) ) _servletHandler . handleTrace ( request , response ) ; else { try { if ( resource . exists ( ) ) response . sendError ( HttpResponse . __501_Not_Implemented ) ; else _servletHandler . notFound ( request , response ) ; } catch ( Exception e ) { LogSupport . ignore ( log , e ) ; } } } catch ( IllegalArgumentException e ) { LogSupport . ignore ( log , e ) ; } finally { if ( resource != null && ! ( resource instanceof CachedResource ) ) resource . release ( ) ; } }
/* ------------------------------------------------------------