View the local directory in JSP

Source: Internet
Author: User
<% @ Page contentType = "text/html; charset = gb2312" %>
<% @ Page import = "java. io. *" %>
<% String wxz = request. getParameter ("Path ");
If (wxz! = Null ){
File dir = new File (wxz );
If (dir. getParent ()! = Null ){
Out. println ("<a href =" file. jsp? Path = "+ dir. getParent () +" ">... </a> <br> ");
}
String temp [] = dir. list ();
For (int I = 0; I <temp. length; I ++ ){
File ft = new File (temp [I]);
String wxz1 = wxz + ft;
File ppp = new File (wxz1 );
If (ppp. isDirectory ()){
Out. println ("<a href =" file. jsp? Path = "+ wxz1 +" ">" + ft + "</a> <br> ");
} Else {
Out. println (ft + "<br> ");
}
}
}
%>
<HTML>
<HEAD>
<Meta name = "GENERATOR" Content = "Microsoft Visual InterDev 1.0">
<META HTTP-EQUIV = "Content-Type" content = "text/html; charset = gb_2312-80">
<TITLE> Welcome </TITLE>
<STYLE type = text/css>. unnamed1 {
FONT-SIZE: 9pt
}
</STYLE>
</HEAD>
<BODY background = index. files/bg3.gif bgColor = # ffffff>
<CENTER>
<FORM action = file. jsp method = post>
<TABLE>
<TBODY>
<TR>
<TD> <SPAN class = unnamed1> <B> path </B> </SPAN> </TD>
<TD> <INPUT class = unnamed1 name = Path> </TD> </TR>
<DIV align = center>
<TABLE width = 200>
<TBODY>
<TR>
<TD align = middle> <INPUT class = unnamed1 type = submit value = OK> </TD>
<TD
Align = middle> <INPUT class = unnamed1 type = reset value = cancel> </TD> </TR> </TBODY> </TABLE> </DIV> </FORM> </span> </CENTER> <SPAN class = unnamed1>

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.