private Resource getConfigDirectory(ServletConfig sg, ConfigServerImpl configServer, int countExistingContextes, RefBoolean isCustomSetting) throws PageServletException {
	isCustomSetting.setValue(true);
	ServletContext sc = sg.getServletContext();
	String strConfig = sg.getInitParameter("configuration");
	if (StringUtil.isEmpty(strConfig)) strConfig = sg.getInitParameter("lucee-web-directory");
	if (StringUtil.isEmpty(strConfig)) strConfig = System.getProperty("lucee.web.dir");

	if (StringUtil.isEmpty(strConfig)) {
	    isCustomSetting.setValue(false);
	    strConfig = "{web-root-directory}/WEB-INF/lucee/";
	}
	// only for backward compatibility
	else if (strConfig.startsWith("/WEB-INF/lucee/")) strConfig = "{web-root-directory}" + strConfig;

	strConfig = StringUtil.removeQuotes(strConfig, true);

	// static path is not allowed
	if (countExistingContextes > 1 && strConfig != null && strConfig.indexOf('{') == -1) {
	    String text = "static path [" + strConfig + "] for servlet init param [lucee-web-directory] is not allowed, path must use a web-context specific placeholder.";
	    System.err.println(text);
	    throw new PageServletException(new ApplicationException(text));
	}
	strConfig = SystemUtil.parsePlaceHolder(strConfig, sc, configServer.getLabels());

	ResourceProvider frp = ResourcesImpl.getFileResourceProvider();
	Resource root = frp.getResource(ReqRspUtil.getRootPath(sc));
	Resource res;
	Resource configDir = ResourceUtil.createResource(res = root.getRealResource(strConfig), FileUtil.LEVEL_PARENT_FILE, FileUtil.TYPE_DIR);

	if (configDir == null) {
	    configDir = ResourceUtil.createResource(res = frp.getResource(strConfig), FileUtil.LEVEL_GRAND_PARENT_FILE, FileUtil.TYPE_DIR);
	}

	if (configDir == null && !isCustomSetting.toBooleanValue()) {
	    try {
		res.createDirectory(true);
		configDir = res;
	    }
	    catch (IOException e) {
		throw new PageServletException(Caster.toPageException(e));
	    }
	}
	if (configDir == null) {
	    throw new PageServletException(new ApplicationException("path [" + strConfig + "] is invalid"));
	}

	if (!configDir.exists() || ResourceUtil.isEmptyDirectory(configDir, null)) {
	    Resource railoRoot;
	    // there is a railo directory
	    if (configDir.getName().equals("lucee") && (railoRoot = configDir.getParentResource().getRealResource("railo")).isDirectory()) {
		try {
		    copyRecursiveAndRename(railoRoot, configDir);
		}
		catch (IOException e) {
		    try {
			configDir.createDirectory(true);
		    }
		    catch (IOException ioe) {}
		    return configDir;
		}
		// zip the railo-server di and delete it (optional)
		try {
		    Resource p = railoRoot.getParentResource();
		    CompressUtil.compress(CompressUtil.FORMAT_ZIP, railoRoot, p.getRealResource("railo-web-context-old.zip"), false, -1);
		    ResourceUtil.removeEL(railoRoot, true);
		}
		catch (Throwable t) {
		    ExceptionUtil.rethrowIfNecessary(t);
		}
	    }
	    else {
		try {
		    configDir.createDirectory(true);
		}
		catch (IOException e) {}
	    }
	}
	return configDir;
    }
private Resource getConfigDirectory ( ServletConfig sg , ConfigServerImpl configServer , int countExistingContextes , RefBoolean isCustomSetting ) throws PageServletException { isCustomSetting . setValue ( true ) ; ServletContext sc = sg . getServletContext ( ) ; String strConfig = sg . getInitParameter ( "configuration" ) ; if ( StringUtil . isEmpty ( strConfig ) ) strConfig = sg . getInitParameter ( "lucee-web-directory" ) ; if ( StringUtil . isEmpty ( strConfig ) ) strConfig = System . getProperty ( "lucee.web.dir" ) ; if ( StringUtil . isEmpty ( strConfig ) ) { isCustomSetting . setValue ( false ) ; strConfig = "{web-root-directory}/WEB-INF/lucee/" ; } else if ( strConfig . startsWith ( "/WEB-INF/lucee/" ) ) strConfig = "{web-root-directory}" + strConfig ; strConfig = StringUtil . removeQuotes ( strConfig , true ) ; if ( countExistingContextes > 1 && strConfig != null && strConfig . indexOf ( '{' ) == - 1 ) { String text = "static path [" + strConfig + "] for servlet init param [lucee-web-directory] is not allowed, path must use a web-context specific placeholder." ; System . err . println ( text ) ; throw new PageServletException ( new ApplicationException ( text ) ) ; } strConfig = SystemUtil . parsePlaceHolder ( strConfig , sc , configServer . getLabels ( ) ) ; ResourceProvider frp = ResourcesImpl . getFileResourceProvider ( ) ; Resource root = frp . getResource ( ReqRspUtil . getRootPath ( sc ) ) ; Resource res ; Resource configDir = ResourceUtil . createResource ( res = root . getRealResource ( strConfig ) , FileUtil . LEVEL_PARENT_FILE , FileUtil . TYPE_DIR ) ; if ( configDir == null ) { configDir = ResourceUtil . createResource ( res = frp . getResource ( strConfig ) , FileUtil . LEVEL_GRAND_PARENT_FILE , FileUtil . TYPE_DIR ) ; } if ( configDir == null && ! isCustomSetting . toBooleanValue ( ) ) { try { res . createDirectory ( true ) ; configDir = res ; } catch ( IOException e ) { throw new PageServletException ( Caster . toPageException ( e ) ) ; } } if ( configDir == null ) { throw new PageServletException ( new ApplicationException ( "path [" + strConfig + "] is invalid" ) ) ; } if ( ! configDir . exists ( ) || ResourceUtil . isEmptyDirectory ( configDir , null ) ) { Resource railoRoot ; if ( configDir . getName ( ) . equals ( "lucee" ) && ( railoRoot = configDir . getParentResource ( ) . getRealResource ( "railo" ) ) . isDirectory ( ) ) { try { copyRecursiveAndRename ( railoRoot , configDir ) ; } catch ( IOException e ) { try { configDir . createDirectory ( true ) ; } catch ( IOException ioe ) { } return configDir ; } try { Resource p = railoRoot . getParentResource ( ) ; CompressUtil . compress ( CompressUtil . FORMAT_ZIP , railoRoot , p . getRealResource ( "railo-web-context-old.zip" ) , false , - 1 ) ; ResourceUtil . removeEL ( railoRoot , true ) ; } catch ( Throwable t ) { ExceptionUtil . rethrowIfNecessary ( t ) ; } } else { try { configDir . createDirectory ( true ) ; } catch ( IOException e ) { } } } return configDir ; }
loads Configuration File from System, from init Parameter from web.xml

@param sg
@param configServer
@param countExistingContextes
@return return path to directory