> Hello this is my first osting to this list hopefully someone can help me
> here.

> Im looking to make a servlet that lists the contents of directory on the
web
> even if there is a default html page for that site.

> Any information would be appreciated.

> LineNoise

Use the java.io.File class to get the contents of a directory:

File myDir = new File("/myPath");
String[] sFileList = myDir.list();

Write them to the Outputstream of the servlet:

response.setContentType("text/html");
PrintWriter out = response.getWriter();
for(int i=0; i < sFileList.length; i++)
{
   out.println(sFileList[i]);
}

You can use one servlet for all the directories and pass the path as an
argument. If you want it to be called automatically if you enter a directory
with your browser, get the servlet called by the default page (via refresh
and/or some javascript stuff).

I think that should work.

Mario

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to