No, you can't list the contents of a remote directory if the server won't
cooperate. And thank goodness. I'd like some security on my websites.
Jim
[EMAIL PROTECTED]
On Thu, 4 Mar 1999, LineNoise wrote:
> >> 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
>
> What if you want to list the contents of a remote directory on the web?
>
> LineNoise
>
> ___________________________________________________________________________
> 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
>
___________________________________________________________________________
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