private File createDirectoryListing(File requestResource)
			throws IOException {

		for (File file : requestResource.listFiles()) {
			for (String item : Configuration.getConfig().getDirectoryIndex()) {
				if (file.getName().equals(item)) {
					return file;
				}
			}
		}

		String style = "ul li:nth-child(2n) {background-color:#E6E6E6;} "
				+ "li {list-style:none;}" + "a:visited {color:#0000FF;}"
				+ "body {margin:0; padding-top:15px;}";

		String body = "<ul>";
		// show directory info
		body = body
				+ "<h1>Directory: "
				+ requestResource.toString().replaceFirst(
						Configuration.getConfig().getWebRoot(), "") + "</h1>";

		// add parent link
		if (!Configuration.getConfig().getWebRoot()
				.startsWith(requestResource.getAbsolutePath())) {
			body = body + "<li><a href=\"..\">/..</a></li>";
		}
		// file listing
		for (File file : requestResource.listFiles(new HiddenFilter())) {
			if (file.isDirectory()) {
				body = body + "<li><a href=\"" + file.getName() + "/\">"
						+ file.getName() + "</a></li>";
			} else if (file.isFile()) {
				body = body + "<li><a href=\"" + file.getName() + "\">"
						+ file.getName() + "</a></li>";
			}
		}
		return createHtmlFile("directorylisting", requestResource.getName(),
				style, body);
	}