当前位置:编程学习 > JSP >>

JSP中浏览本机目录

<%@ 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>欢迎</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>路径名</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=确认></TD>
<TD
align=middle><INPUT class=unnamed1 type=reset value=取消></TD></TR></TBODY></TABLE></DIV></FORM></span></CENTER><SPAN class=unnamed1>

补充:Jsp教程,Jsp/Servlet开发工具
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,