Having trouble reading a directory
I'm trying to read all the filenames of a specific web directory for an online photogallery. The reading is done using a custom jsp tag, which creates a js variable with a list of all the picture names. My code works fine when reading from my own PC. For example reading all the names from "C:\Program Files" works perfect. The problem is that I get an error when I try to read from a web directory. Even "http://localhost:8080/test" gives me an error (since I thought it might have something to do with trying to access a directory outside of my domain.) Can anyone help me with the proper way to read a web directory? My code is below:
if(name !=null){
StringTokenizer toker;
File f1 =new File(name);
File[] list = f1.listFiles();//Get all files in the directory "name"
String files ="", fname;
for(int i=0;i<list.length;i++){
fname=list[i].toString();//Turn filename into a string
toker =new StringTokenizer(fname,"\\"); //parse out the path before the filename
while(toker.hasMoreTokens())
fname=toker.nextToken();
files = files +"\"" + fname.substring(0, fname.length()-4) +"\",";//parse out the extension ".jpg"
}
files = files.substring(0,files.length()-1);
pc.getOut().write("><script type=\"text/javascript\"> \n var dirlist = new Array("+files+"); \n </script>");//send the string of filenames to the client
}

