public void init()
        throws ServletException
    {
        _env= new EnvList();
        _cmdPrefix=getInitParameter("commandPrefix");

        String tmp = getInitParameter("cgibinResourceBase");
        if (tmp==null)
            tmp = getServletContext().getRealPath("/");

        if(log.isDebugEnabled())log.debug("CGI: CGI bin "+tmp);

        if (tmp==null)
        {
            log.warn("CGI: no CGI bin !");
            throw new ServletException();
        }

        File dir = new File(tmp);
        if (!dir.exists())
        {
            log.warn("CGI: CGI bin does not exist - "+dir);
            throw new ServletException();
        }

        if (!dir.canRead())
        {
            log.warn("CGI: CGI bin is not readable - "+dir);
            throw new ServletException();
        }

        if (!dir.isDirectory())
        {
            log.warn("CGI: CGI bin is not a directory - "+dir);
            throw new ServletException();
        }

        try
        {
            _docRoot=dir.getCanonicalFile();
            if(log.isDebugEnabled())log.debug("CGI: CGI bin accepted - "+_docRoot);
        }
        catch (IOException e)
        {
            log.warn("CGI: CGI bin failed - "+dir);
            e.printStackTrace();
            throw new ServletException();
        }

        _path=getInitParameter("Path");
        if(log.isDebugEnabled())log.debug("CGI: PATH accepted - "+_path);
        if (_path != null)
            _env.set("PATH", _path);

        Enumeration e= getInitParameterNames();
        while (e.hasMoreElements())
        {
            String n= (String)e.nextElement();
            if (n != null && n.startsWith("ENV_"))
                _env.set(n.substring(4),getInitParameter(n));
        }
    }
public void init ( ) throws ServletException { _env = new EnvList ( ) ; _cmdPrefix = getInitParameter ( "commandPrefix" ) ; String tmp = getInitParameter ( "cgibinResourceBase" ) ; if ( tmp == null ) tmp = getServletContext ( ) . getRealPath ( "/" ) ; if ( log . isDebugEnabled ( ) ) log . debug ( "CGI: CGI bin " + tmp ) ; if ( tmp == null ) { log . warn ( "CGI: no CGI bin !" ) ; throw new ServletException ( ) ; } File dir = new File ( tmp ) ; if ( ! dir . exists ( ) ) { log . warn ( "CGI: CGI bin does not exist - " + dir ) ; throw new ServletException ( ) ; } if ( ! dir . canRead ( ) ) { log . warn ( "CGI: CGI bin is not readable - " + dir ) ; throw new ServletException ( ) ; } if ( ! dir . isDirectory ( ) ) { log . warn ( "CGI: CGI bin is not a directory - " + dir ) ; throw new ServletException ( ) ; } try { _docRoot = dir . getCanonicalFile ( ) ; if ( log . isDebugEnabled ( ) ) log . debug ( "CGI: CGI bin accepted - " + _docRoot ) ; } catch ( IOException e ) { log . warn ( "CGI: CGI bin failed - " + dir ) ; e . printStackTrace ( ) ; throw new ServletException ( ) ; } _path = getInitParameter ( "Path" ) ; if ( log . isDebugEnabled ( ) ) log . debug ( "CGI: PATH accepted - " + _path ) ; if ( _path != null ) _env . set ( "PATH" , _path ) ; Enumeration e = getInitParameterNames ( ) ; while ( e . hasMoreElements ( ) ) { String n = ( String ) e . nextElement ( ) ; if ( n != null && n . startsWith ( "ENV_" ) ) _env . set ( n . substring ( 4 ) , getInitParameter ( n ) ) ; } }
/* ------------------------------------------------------------