Ask a question about the absolute path and relative path of jsp

Source: Internet
Author: User

<% @ 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>

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.