save the following code to a jsp page, name it Jsp1.jsp, then execute it using tomcat,
offcourse it's primitive, but I hope it will help,
<%@ page import="java.io.*"%>
<html>
<head>
<title>
Directory List
</title>
</head>
<body>
<%
String fileName=request.getParameter("fileName");
if (fileName==null) fileName="c:/";
fileName=fileName.trim();
%>
<form method="post">
<%File file=new File(fileName);
File sons[] = file.listFiles();
for(int i=0;i<sons.length;i++){
out.println("<br>");
if (sons[i].isDirectory())
out.println("<a href='Jsp1.jsp?fileName="+sons[i].toString().replace('\\','/')+"'>"+sons[i]+"</a>");
else
out.println(sons[i]);
}
%>
</form>
</body>
</html>
MHD Yasir Al-lahham
|