List files in a directory using JSP

This JSP code will display a specified directory and all the files contained in that directory.  I used it to display a list of daily logs.

 

<jsp:include page="../includes/header.jsp">
 <jsp:param name="report" value="active"/>
 <jsp:param name="title" value="Your Title"/>
 </jsp:include>
 <!-- ************************************************************************************************** -->

<%!
 public void GetDirectory( String the_Path , Vector the_files , Vector the_folders )
 {
 File c_Directory = new File( the_Path ) ;
 File [] c_files = c_Directory.listFiles() ;

for( int c = 0 ; c < c_files.length ; c ++ ) {
 if( c_files[c].isDirectory() ) {
 the_folders.add( c_files[c].getName() ) ;
 } else {
 the_files.add( c_files[c].getName() ) ;
 }
 }

Comparator comparator = Collections.reverseOrder();
 Collections.sort(the_files,comparator);
 }

%>

<% Vector c_Files = new Vector() , c_Folders = new Vector() ; %>
 <form name="listForm" method="POST">
 <table width="100%">
 <tr>
 <td colspan=2>
 <br />
 Page description<br /><br />
 </td>
 </tr>

<tr>
 <td colspan=2>
 <span class="oneUp">Logs<br /><br /></span>
 </td>
 </tr>

<tr>
 <td colspan=2>
 &nbsp;
 </td>
 </tr>
 <tr>
 <td class="indent">
 <%
 //GettheDirectory( "/home/you/output/", c_Files, c_Folders) ;
 GettheDirectory( "C:/Documents and Settings/output/", c_Files, c_Folders) ;

out.println("<select name='thelogfile'>") ;

for( int a = 0 ; a<c_Files.size() ; a++ )
 out.println("<option value='"+ c_Files.elementAt(a).toString() +"'>" + c_Files.elementAt(a).toString() + "</option>") ;

out.println("</select>") ;
 %>
 </td>
 <td>
 <span class="button"><input type="button" value="Show" onclick="gettheFile()" /></span>
 - Shows the log file.
 </td>
 </tr>
 <tr><td colspan=2><div>&nbsp;</div><br /></td></tr>

</table>
 <br />

</form>
 <br />

<script language="javascript">

var form = document.listForm;

function gettheFile() {
 var ndx = form.thelogfile.selectedIndex;
 var filename = form.thelogfile[ndx].value;
 location.href="../output/the/"+filename;
 }
 form.thelogfile.selectedIndex = 0;
 </script>

<jsp:include page="../includes/footer.jsp"/>
list files in a directory using jsp