boolean included=false; String servletPath=(String)request.getAttribute(Dispatcher.__INCLUDE_SERVLET_PATH);
String servletPath=null;
    protected void doGet(HttpServletRequest request, HttpServletResponse response)    	throws ServletException, IOException    {        boolean included=false;        String servletPath=(String)request.getAttribute(Dispatcher.__INCLUDE_SERVLET_PATH);        String pathInfo=null;        if (servletPath==null)        {            servletPath=request.getServletPath();            pathInfo=request.getPathInfo();        }        else        {            included=true;            pathInfo=(String)request.getAttribute(Dispatcher.__INCLUDE_PATH_INFO);        }                String pathInContext=URIUtil.addPaths(servletPath,pathInfo);        boolean endsWithSlash=pathInContext.endsWith("/");                // Is this a range request?        Enumeration reqRanges = included?null:request.getHeaders(HttpHeaders.RANGE);        if (reqRanges!=null && !reqRanges.hasMoreElements())            reqRanges=null;                // Can we gzip this request?        String pathInContextGz=null;        boolean gzip=false;        if (_gzip && reqRanges==null && !endsWithSlash )        {            String accept=request.getHeader(HttpHeaders.ACCEPT_ENCODING);            if (accept!=null && accept.indexOf("gzip")>=0)                gzip=true;        }                // Find the resource and content        String path=null;        Resource resource=null;        ResourceCache.Entry cache=null;        Content content=null;        try        {               // Try gzipped content first            if (gzip)            {                pathInContextGz=pathInContext+".gz";  // TODO grrrr - hate having to do this every request!                if (_cache==null)                    resource=getResource(pathInContextGz);                else                {                    cache=_cache.lookup(pathInContextGz,this);                                      if (cache!=null)                    {                        resource=cache.getResource();                        content=(Content)cache.getValue();                    }                    else                        resource=getResource(pathInContextGz);                }            }                        // If we did not find a gzipped resource            if (resource!=null && resource.exists())            {                path=pathInContextGz;            }            else            {                pathInContextGz=null;                gzip=false;                path=pathInContext;                                // look for normal resource                if (_cache==null)                    resource=getResource(pathInContext);                else                {                    cache=_cache.lookup(pathInContext,this);                                        if (cache!=null)                    {                        resource=cache.getResource();                        content=(Content)cache.getValue();                    }                    else                        resource=getResource(pathInContext);                }            }                        if (Log.isDebugEnabled())                Log.debug("resource="+resource+(cache!=null?" cache":"")+(content!=null?" content":"")+(gzip?" gzip":""));                                    // Handle resource            if (resource==null || !resource.exists())                response.sendError(HttpServletResponse.SC_NOT_FOUND);            else if (!resource.isDirectory())            {                // Handle gzipping                if (gzip)                {                   response.setHeader(HttpHeaders.CONTENT_ENCODING,"gzip");                   response.setHeader(HttpHeaders.CONTENT_TYPE,_context.getMimeType(pathInContext));                }                                // ensure we have content                if (content==null)                {                    content=getContent(path,resource);                    // validate the cache entry if we have one;                    if (cache!=null)                        cache.setValue(content);                }                                if (included || passConditionalHeaders(request,response, resource,content))                      sendData(request,response,included,resource,content,reqRanges);               }            else            {                String welcome=null;                                if (!endsWithSlash && !pathInContext.equals("/"))                {                    String q=request.getQueryString();                    StringBuffer buf=request.getRequestURL();                    if (q!=null&&q.length()!=0)                    {                        buf.append('?');                        buf.append(q);                    }                    response.setContentLength(0);                    response.sendRedirect(response.encodeRedirectURL(URIUtil.addPaths(buf.toString(),"/")));                }                // else look for a welcome file                else if (null!=(welcome=getWelcomeFile(resource)))                {                    String ipath=URIUtil.addPaths(pathInContext,welcome);                    if (_redirectWelcome)                    {                        // Redirect to the index                        response.setContentLength(0);                        response.sendRedirect(URIUtil.addPaths( _context.getContextPath(),ipath));                    }                    else                    {                        // Forward to the index                        RequestDispatcher dispatcher=request.getRequestDispatcher(ipath);                        if (dispatcher!=null)                            dispatcher.forward(request,response);                    }                }                else                 {                    content=getContent(pathInContext,resource);                    if (included || passConditionalHeaders(request,response, resource,content))                        sendDirectory(request,response,resource,pathInContext.length()>1);                }            }        }        catch(IllegalArgumentException e)        {            Log.warn(Log.EXCEPTION,e);        }        finally        {            if (cache!=null && cache.getValue()==null)                cache.invalidate();            if (content!=null)                content.release();            else if (resource!=null)                resource.release();        }            }