Log.debug("CGI: _path       : " + _path); Log.debug("CGI: _ignoreExitState: " + _ignoreExitState);
  public void service(HttpServletRequest req, HttpServletResponse res)              throws ServletException, IOException  {    String pathInContext = StringUtil.nonNull(req.getServletPath())                         + StringUtil.nonNull(req.getPathInfo());    if (Log.isDebugEnabled())    {      Log.debug("CGI: ContextPath : " + req.getContextPath());      Log.debug("CGI: ServletPath : " + req.getServletPath());      Log.debug("CGI: PathInfo    : " + req.getPathInfo());      Log.debug("CGI: _docRoot    : " + _docRoot);    }    // pathInContext may actually comprises scriptName/pathInfo...We will    // walk backwards up it until we find the script - the rest must    // be the pathInfo;    String both = pathInContext;    String first = both;    String last = "";    File exe = new File(_docRoot, first);    while ((first.endsWith("/") || !exe.exists()) && first.length()>=0)    {      int index = first.lastIndexOf('/');      first = first.substring(0, index);      last=both.substring(index, both.length());      exe = new File(_docRoot, first);    }    if (first.length()==0 || !exe.exists() || exe.isDirectory() ||        !exe.getCanonicalPath().equals(exe.getAbsolutePath()))    {      res.sendError(404);    }    else    {      if (Log.isDebugEnabled())      {        Log.debug("CGI: script is " + exe);        Log.debug("CGI: pathInfo is " + last);      }      exec(exe, last, req, res);    }  }