DisplayFile. java
//*********************************
File parentDirectory = null; // Current Directory
ArrayList [] file = null; // stores all files in the current directory
ArrayList [] directory = null; // stores all directories in the current directory
String [] temp = null; // temporary array stores all files in the current directory and the absolute path of the Directory plus the String with the complete name
File tempFile = null;
If (request. getParameter ("directory") = null)
{
ParentDirectory = new File ("C: // temp"); // use the default directory for accessing objects using SERVLET for the first time
}
Else
{
// The Directory submitted on the page for the second or later access is the default directory
ParentDirectory = new File (request. getParameter ("directory "));//
}
Temp = parentDirectory. list (); // extract the absolute path of all files and directories in the current directory and add the string with the complete name
For (int I = 0; I <list. length (); I ++ ){
// Check whether the directory is put into the directory set and the files are put into the file set
TempFile = new File (temp)
If (tempFile. isDirectory ())
Directory. add (tempFile );
Else
File. add (tempFile );
}
//*********************************
Then, use the two sets on the JSP page to display the Directory and file directory. You can use the super connection to call the Servlet above again.
"DisplayFile? Directory = <% (File) file. get (I). getName () %>"
If there is no environment, it is inevitable that there will be a problem ~~~~