|
Hi: I was also looking for this code, and found
ARUN's example, so I put it in a servlet.
Thanks,
Roger
import java.io.*;
import java.text.*; import java.util.*; import javax.servlet.*; import javax.servlet.http.*; public class FileListing extends HttpServlet
{
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { String strFile = "";
String prepend = "<a href="\"/rwsJSPweb/jobs/"; String append = "</a>"; String strFilePath = "D://tomcat321//webapps//rwsJSPweb//jobs"; response.setContentType("text/html"); PrintWriter out = response.getWriter();
out.println("<html>");
out.println("<head>"); out.println("<title>File Listing</title>"); out.println("</head>"); out.println("<body bgcolor=\"white\">"); out.println("<a href="\"javascript:window.history.go(-1);\"><b>Go" Back</b></a>"); out.println("<h1>File Listing for <b>" + strFilePath + "</b></h1>"); out.println("<hr>"); File file = new File(strFilePath); File[] f = file.listFiles(); if (f != null) { for(int i = 0; i < f.length; i++) { if(!(f[i].isDirectory())) { strFile = f[i].getName(); out.println("<br>" + prepend + strFile + "\">" + strFile + append); } } } out.println("</body>"); out.println("</html>"); } } 45 Punchbowl Trail W. Kingston, RI 02892 [EMAIL PROTECTED] cell: 401-862-5621 |
