code: 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: req.getContextPath() : "+req.getContextPath());
          if(log.isDebugEnabled())log.debug("CGI: req.getServletPath() : "+req.getServletPath());
          if(log.isDebugEnabled())log.debug("CGI: req.getPathInfo()    : "+req.getPathInfo());
          if(log.isDebugEnabled())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.getCanonicalPath().equals(exe.getAbsolutePath()) ||
              exe.isDirectory())
              res.sendError(404);
          else
          {
              if(log.isDebugEnabled())log.debug("CGI: script is "+exe);
              if(log.isDebugEnabled())log.debug("CGI: pathInfo is "+last);
  
              exec(exe, last, req, res);
          }
      }
docs: /* ------------------------------------------------------------