Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

how do i list the files from the web server?

 
Rick Hunter
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how do i list the files from the web server? i also need to show the filesize, and the date modified.
sample code in JSP would really help!
 
sharad goswami
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear friend i don't know about other servers but as far as tomcat is concerned the listing is very easy.
Proivde a link of rlative path and your are on.
I mean incae you have given relative path as /sharad which means c:/sharad/jsp
and your site is www.my.com if your type www.my.com/sharad you will have listing of all files and folder in c:/sharad/jsp listed.. try it.
 
chanoch wiggers
Author
Ranch Hand
Posts: 245
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
if you want to list files from a specific directory then it goes something like this. I've provided it as a method so that it can be called iteratively to list ALL files within the directory including subdirectories - I'm sure you can figure out how to provide a switch to define iteration or not:
public Vector listFiles(String foldername) {
Vector fileList = new Vector(20);
// foldername should be an absolute ref
File folder = new File("folder name");
if(file.isDirectory()) {
File[] files = folder.listFiles()
for(int i=0; i<files.length; i++) {
if(files[i].isFile()) {
fileList.add(files[i].getName();
} else {
listFiles(files[i].getAbsoluteName();// i think
}
}
}
}
you might need to tweak that = hope it helps.
 
I like tacos! And this tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!