private static byte[] processDirectory(Request request, String IP_address, String port, String serverRootDir) {

		String path = getFilePathFromRequest(request, serverRootDir);
		File file;
		file = new File(path);

		String[] file_list = file.list();

		StringBuffer responce1;

		String responce_header;
		String server_addr = "http://" + IP_address + ":" + port;
		String Folder_Icons_Path = server_addr + "/folder.jpg";
		String File_Icons_Path = server_addr + "/file.png";

		String intermediate_URI = request.get("URI").substring(1);
		String back_URI;

		responce1 = new StringBuffer("<html><head><title>Mini HTTP Server</title></head><body>");
		responce1.append("<p ><h1><i>Mini HTTP Server</h1></i></p><hr width=600 align=left></br>");
		responce1.append("<Table border=0>");
		responce1.append("<TR>");
		responce1.append("<TD width='50'> </TD>");
		responce1.append("<TD><strong>Name</strong></TD>");
		responce1.append("<TD align='center'><strong>Last Modified</strong></TD>");
		responce1.append("<TD align='center' width='50'><strong>Size</strong></TD>");
		responce1.append("</TR>");

		for (int i = 0; i < file_list.length; i++) {

			responce1.append("<TR>");

			if (new File(path + "/" + file_list[i]).isDirectory()) {

				responce1.append("<TD width='50'><img src=\"" + Folder_Icons_Path + "\" height=22 widhth=22></TD>");
				if (! intermediate_URI.equalsIgnoreCase(""))
					responce1.append("<TD><a href='" + server_addr + '/' + intermediate_URI + '/' + file_list[i] + "'>" + file_list[i] + "</a>"+ "</TD>");
							
				else
					responce1.append("<TD><a href='" + server_addr + '/' + file_list[i] + "'>" + file_list[i] + "</a>" + "</TD>");

				responce1.append("<TD align='center' width='300'>" + new Date(new File(path + "\\" + file_list[i]).lastModified()).toString()+ "</TD>");
						
				responce1.append("<TD align='center' width='50'><font color=red><strong>&lt;DIR&gt;</strong></font></TD>");

			}
			else {
				responce1.append("<TD width='50'><img src=\"" + File_Icons_Path + "\" height=22 widhth=22 ></TD>");
				if (! intermediate_URI.equalsIgnoreCase(""))
					responce1.append("<TD><a href='" + server_addr + '/' + intermediate_URI + '/' + file_list[i] + "'>" + file_list[i] + "</a>"+ "</TD>");
							
				else
					responce1.append("<TD><a href='" + server_addr + '/' + file_list[i] + "'>" + file_list[i] + "</a>" + "</TD>");
				responce1.append("<TD align='center' width='300'>" + new Date(new File(path + "\\" + file_list[i]).lastModified()).toString()+ "</TD>");
						
				responce1.append("<TD align='center' width='50'><font color=red><strong>"
						+ String.valueOf(new File(path + "\\" + file_list[i]).length()) + "</font></strong></TD>");

			}
			responce1.append("</TR>");
		}
		if (! intermediate_URI.equalsIgnoreCase("")) {
			if (! intermediate_URI.contains("/")) {
				back_URI = "";
				intermediate_URI = "";
			}
			else {
				back_URI = intermediate_URI.split("/(?=[^/]+$)")[0];
			}
			responce1.append("<TR><TD></TD><TD><B><a href=" + server_addr + '/' + back_URI + ">\\..</a></B></TD></TR>");
		}
		responce1.append("</TABLE></br><hr width=600 align=left><i>Mini HTTP Server at <u><a href="+server_addr+">"+server_addr+"</a></u></i></body></html>");

		responce_header = getResponceHeaders(200) + "Content-type:" + "text/html" + CRLF + "Content-Length:" + ("" + responce1).getBytes().length
				+ CRLF + CRLF;

		return (responce_header + responce1).getBytes();
	}