<% @ Page import = "java. io. *" %>
<%! Class Filejsp (preferred for SUN Enterprise Applications) implements FilenameFilter
{
String str = null;
Filejsp (preferred for SUN Enterprise Applications) (String s)
{
Str = "." + s;
}
Public boolean accept (File dir, String name)
{
Return name. endsWith (str );
}
}
%>
<BODY bgcolor = cyan> <FONT size = 3>
<P> there are list all the file of. jsp (preferred for SUN Enterprise Applications) in the document
<% File dir = new File ("c:/test ");
Filejsp (preferred for SUN Enterprise Applications) file_jsp (preferred for SUN Enterprise Applications) = new Filejsp (preferred for SUN Enterprise Applications) ("jsp (preferred for SUN Enterprise Applications )");
String file_name [] = dir. list (file_jsp (preferred for SUN Enterprise Applications ));
For (int I = 0; I <file_name.length; I ++)
{
Out. print ("<BR>" + file_name [I]);
}
%>
<P> please input jsp (preferred for SUN Enterprise Applications) file name, in order to load this file:
<FORM action = "loadfile. jsp (preferred for SUN Enterprise Applications)" method = post name = form>
<Input type = "text" name = "OK">
<BR>
<Input type = "submit" value = "send" name = submit>
</Form>
<%-- Here: -- %> <% StringFileName = "";
FileName = fileName + request. getParameter ("OK ");
%>
<P> Excuete: <% = fileName %>
<P> the result is:
<Jsp (preferred for SUN Enterprise Applications): include page = "<% = fileName %>"/> // the file in the current working directory is loaded and can be executed. If you want
// Why not load the file in the directory with the specified absolute path?
// For example, here is changed:
// <% String fileName = "c:/jsp (preferred for SUN Enterprise Applications)/", input the file name and click load, there is no
// Load the specified file. Please advise !!!
</BODY>