读取当前目录的jsp文件
文件名:wenjian.jsp
wenjian.jsp调用test包中的CatalogShow.class来读取当前目录下的文件
<%@ page contentType="text/html;charset=gb2312"%>
<%@ page import="java.io.File"%>
<jsp:useBean id="list" class="test.CatalogShow" scope="session" />
<%
String str=request.getParameter("path");
String path=null;
if(str!=null) path=new String(str.getBytes("ISO8859_1"),"GBK");
//String path=request.getParameter("path");
if(path==null)
{
path="D:";
}
list.setPath(path);
File[] files=list.listFiles();
int i=0;
%>
路径:
<% out.println(list.getPath());%>
<br>
<%! int fcount=0,dcount=0;%>
<%
path=list.dirUp(path);
if(path!=null)
{%>
<a href=wenjian.jsp?path=<%=path%>>shjimulu</a>
<%}%>
<%
for(i=0;i<files.length;i++)
{
out.print("<tr>");
path=list.addPath(files<i>.getName());
if(files<i>.isDirectory())
{%>
<a href=wenjian.jsp?path=<%=path%>><%=files<i>.getName()%>
<%=files<i>.length()%></a>
<%dcount++;
}else{%>
<%=files<i>.length()%>
<% fcount++;}
}%><br>
The number of CataLog :<%=dcount%><br>
The number of files:<%=fcount%>
lunzi
2005-06-13 03:04:12
评论:0
阅读:2806
引用:0
