I want to display all files from a particular folder in a JSP dropdown and upon selection i want to display all the details in it. Any idea how to achieve this?
Asked
Active
Viewed 1,313 times
0
-
check this http://stackoverflow.com/questions/5778525/want-to-display-file-list-using-jsp – Satya Nov 13 '13 at 04:09
-
You can't unless you're talking about files on the server. – developerwjk Nov 13 '13 at 17:42
-
No guys actually what i listed the files in the directory to a array. and displayed that in the select. And then got the filepath and then called the BufferedReader File Reader to do the remaining work. @developerwjk Thanks for your suggestion though :) – Allen Savio Nov 19 '13 at 13:56
-
^@Satya : I got it . i did it in above method. Thanks. – Allen Savio Nov 19 '13 at 13:59
1 Answers
0
Firstly you need to list the files in the folder
public class ListFiles
{
public static void main(String[] args)
{
// Directory path here
String path = ".";
String files;
File folder = new File(path);
File[] listOfFiles = folder.listFiles();
for (int i = 0; i < listOfFiles.length; i++)
{
if (listOfFiles[i].isFile())
{
files = listOfFiles[i].getName();
System.out.println(files);
}
}
}
}
and then display the array in select
<select><option>array values</option><select>
and then upon select read from the files
using BufferedReader..

Community
- 1
- 1

Allen Savio
- 151
- 2
- 16