站内搜索: 请输入搜索关键词

当前页面: 开发资料首页JSP 专题请教一个jsp绝对路径和相对路径的问题

请教一个jsp绝对路径和相对路径的问题

摘要: 请教一个jsp绝对路径和相对路径的问题

<%@ page import="java.io.*"%>
<%! class FileJSP implements FilenameFilter
{
String str=null;
FileJSP(String s)
{
str="."+s;
}
public boolean accept(File dir,String name)
{
return name.endsWith(str);
}
}
%>
<body bgcolor=cyan>

there are list all the file of .jsp in the document
<%File dir=new File("c:/test");
FileJSP file_jsp=new FileJSP("jsp");
String file_name[]=dir.list(file_jsp);
for(int i=0;i{
out.print("
"+file_name[i]);
}
%>

please input jsp file name,in order to load this file:
<form action="loadfile.jsp" method=post name=form>
<input type="text" name="ok">


<input type="submit" value="send" name=submit>
</form>
<%--here: --%> <%String fileName="";

fileName=fileName+request.getParameter("ok");
%>

Excuete :<%=fileName%>

the result is:

//此处加载的是当前工作目录的文件,可以执行。可如果想
//加载指定了绝对路径的目录的文件为什么不可以?
//比如:here处改为:
//<%String fileName="c:/jsp/",输入文件名点击加载,根本就没有
//加载指定文件,请高手指教!!!

</body>



↑返回目录
前一篇: jsp中图片处理相关操作
后一篇: jsp+javabean开发模式下,数据库sql语句的编写规范