0

I want to get all the file names in a JSP's server directory, and to do that i thought that it would be need some foreach statement, how to do that?

Nore
  • 111
  • 2
  • 4
  • 20

1 Answers1

1

Try this:

File file = new File(request.getRealPath(request.getServletPath()));
File[] fileList = file.getParentFile().listFiles();

You can iterate over this fileList like this:

for (File file : fileList) {
  // Do whatever you want
}
Kuldeep Jain
  • 8,409
  • 8
  • 48
  • 73