Click to See Complete Forum and Search --> : Populate a drop down list with directory contents


afcdave
01-30-2003, 12:30 PM
At the moment i have a static drop down list which consists of a number of options and their associated values. However I want the menu to contain links to the entire contents of a specific directory on my server (c:\stylesheets). I cannot simply hard code the drop down list as the client has the option to upload additional files to the same directory. Does anyone have any suggestions on how I would achieve this? I am using JSP, Java and Javascript.


******Code extract*********

<form action="dummy" method="post" name="choiceform">
<p><select name="choice" size="1" onchange="getvalue()">
<option value>CHOOSE A STYLESHEET</option>
<option value="http://localhost/cocoon/csse/xmldb/collegedb/0801">CSSE</option>
<option value="http://localhost/cocoon/arts/xmldb/collegedb/0801">ARTS</option>
</select><input TYPE="button" VALUE="GO!" onClick="jump(this.form)">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<a href="http://localhost/uploadbean/Upload.jsp"><strong>Submit your own
stylesheet</strong></a><br>
</p>
</form>


:confused:

khalidali63
01-30-2003, 11:56 PM
No big deal( since you are already using Java).
Use java File class to look for the folder you are interested.
File file = new File("file path");

then get a list of all files in this directory

File[] fileList = file.list();

Now you have an array of all the files in this directory,use it as you wish in your case you would want to have

fileList[n].name()

to get you a string containing file name.

cheers

Khalid

afcdave
01-31-2003, 04:20 AM
Thanks for the advice, I'll give it a go with Java.

Cheers,