欢迎光临
我们一直在努力

JSP单页面网站文件管理器-JSP教程,Jsp/Servlet

建站超值云服务器,限时71元/月

这个文件的开发的设计思想是这样的。有的web 网站,或者b/s 软件的客户,在软件的安装调试阶段,往往对某些细节有特殊要求,也许,是字体的调整,也许是界面方面的小改动意见。面对这样的情况,如果用户没有开放ftp 功能,则开发和维护人员往往就必须亲临现场做一些很小的调试工作。

即浪费了时间,也浪费了人力物力。

在这样的情况下,我开发了这个具有文件管理功能的 jsp 单页面文件。它提供了文件夹的新增,更名,删除;文件的修改,更名,删除和上传的功能。基本能满足在软件的安装调试阶段,小的修改工作。

为了安全原因,该jsp 页面提供了简单的用户登陆功能。

使用前,把该文件置于网站文件,或者b/s 产品的任意目录下。开放文件安装目录的 读写 操作权限。用户远程登陆该jsp 页面,就可以行使管理功能。当安装维护阶段结束以后,请修改文件安装目录的 读写 权限,并删除该文件,以免留下安全隐患。

缺省,登陆用户名为:admin 密码为:oddworld

开发环境 jakarta-tomcat-4.0.3.exe

注意:因为本软件的上传文件功能必须有 smartupload 组件支持。请把smartupload 置于tomcat 对应文件夹web-inf 下。如果你支持上传的组件有所不同,请自行调整。

简要开发说明:因为本文件并不复杂,加上本人自我感觉,文档说明虽然不规范,却也详细,所以只打算简要的关于一些小细节上做说明。

1. 本文件进行文件目录操作的时候,直接把目录当参数来传递,没有进行相应的转换。这是因为在 java 中, “英文字符”有可能会被认为是转意字符,而引起在字符处理过程中出现无法预期的问题,所以我认为直接把目录来作为参数,在操作上比较合理。

2. 本文件在一些表单的提交方面,使用连接,而不是按钮,是因为 javascript 处理带 “”的字符串时,也会有处理转意字符的可能,所以,为了防止这样的情况,所以传递目录参数的提交,都使用连接形式。

3. strstat,strerr 两个字符串,贯穿文件始终,前者为页面进行何种操作的判断命令,后者为在所有操作中出错的信息提示。

4. 本文件有可能引起的安全或者其它方面的纠纷,本人不做任何解释。我只是把该文件作为一个免费的工具提供给大家参考,使用。

—————————————————————-

文件内容 admin.jsp

<%– oddworld 网站文件管理系统(简体中文版) 2003年10月10日

copy right by joard ast

admin.jsp 功能:网站文件后台管理页面。

–%>

<%@ page contenttype="text/html;charset=gb2312" %>

<%@ page import="java.io.*" %>

<%@ page import="java.util.date" %>

<%@ page import="com.jspsmart.upload.smartupload" %>

<%@ page import="javax.servlet.http.httpsession" %>

<%@ page import="javax.servlet.http.httpservletrequest" %>

<%@ page import="java.lang.reflect.*" %>

<% //中文字符转换%>

<%!

public static string unicodetochinese(string s){

try{

if(s==null||s.equals("")) return "";

string newstring=null;

newstring=new string(s.getbytes("iso8859_1"),"gb2312");

return newstring;

}

catch(unsupportedencodingexception e)

{

return s;

}

}

public static string chinesetounicode(string s){

try{

if(s==null||s.equals("")) return "";

string newstring=null;

newstring=new string(s.getbytes("gb2312"),"iso8859_1");

return newstring;

}

catch(unsupportedencodingexception e)

{

return s;

}

}

%>

<%

//刷新问题

response.setheader("pragma","no-cache");

response.setheader("cache-control","no-cache");

response.setdateheader("expires", 0);

//自定义登陆用密码和用户名

//正确的用户名

string username="admin"

//正确的密码

string userpass="oddworld";

//得到系统路径

servletcontext app=(servletcontext)pagecontext.getservletcontext();

string strsyspath = app.getrealpath("/");

//处理对象物理路径

string strdealpath="";

//显示错误信息

string strerr="";

//代表页面的显示状态,login 是显示登陆页面;show 是正常的显示文件信息;edit 是显示编辑文件的页面;editdo 是编辑文件的写入操作

;createf 是显示创建文件夹的页面;createfdo 是创建文件夹的操作;renamefold 是显示更改文件夹名称的页面;renamefolddo 是更改文

件夹名称的操作;delfolddo 是删除文件夹的操作;renamefile 是显示更改文件名称的页面;renamefiledo 是更改文件名称的操作;

delfiledo 是删除文件的操作;uploadfile 是显示上传文件的页面;uploadfiledo 是上传文件的操作;

string strstat="login";

//用于show 状态下显示文件的数组

file[] filearr=null;

//根据传递的路径参数得到要处理对象的物理路径

if (request.getparameter("path")==null || request.getparameter("path").equals("")){

strdealpath=strsyspath;

}else{

//得到路径参数

strdealpath=unicodetochinese(request.getparameter("path"));

}

//检查session 的值是否存在,如果不存在着显示错误信息

//httpsession session = request.getsession(false);

if (session.getvalue("loginin")==null || !session.getvalue("loginin").equals("pass"))

{

strstat="login";

strerr="你还没有登陆或者登陆超时,请重新登陆!";

}

//创建file 对象,检查目录是否存在

file myfile=new file(strdealpath);

//检验文件夹是否存在

if(!myfile.exists()){

strerr="你选择的文件夹不存在,请重新选择!";

}

//根据参数的不同,进行对应的操作

if(request.getparameter("act")==null || request.getparameter("act").equals("") ||

request.getparameter("act").equals("login"))

{

if(request.getparameter("username")!=null && request.getparameter("userpass")!=null)

{

//正确的经过md5 加密的密码

//string userpass="oeeo99107dc8c1ee2e06666b965601ef";

if(request.getparameter("username").equals(username) && (request.getparameter("userpass")).equals(userpass))

{

session.putvalue("loginin","pass");

response.sendredirect(request.getrequesturi()+"?act=show");

}

}

else {

strstat="login";

strerr="你还没有登陆或者登陆超时,请重新登陆!";

}

}else if(request.getparameter("act").equals("show")){

//缺省,页面正常显示文件的信息 statstat="show"

strstat="show";

//创建文件列表数组

filearr=myfile.listfiles();

}else if(request.getparameter("act").equals("edit"))

{

//编辑文件内容的页面

//根据是否有request.getparameter("file"),以及相应文件是否存在,如果有,则进行编辑操作,如果没有,则显示错误提示信息

if (!(request.getparameter("file")==null || request.getparameter("file").equals(""))){

file fileedit=new

file(unicodetochinese(request.getparameter("path"))+unicodetochinese(request.getparameter("file")));

if(fileedit.exists())

//文件编辑操作,实际就是更改页面的显示,用一个textarea 显示文件的信息,来做编辑

strstat="edit";

else

//显示错误信息

strerr="你选择的文件不存在,请重新选择!";

}else{

strerr="你没有选择要编辑的文件,请重新选择!";

}

}else if(request.getparameter("act").equals("editdo"))

{

//把修改的内容写入文件,并且返回修改页面

if (!(request.getparameter("file")==null || request.getparameter("file").equals("")))

{

file fileedit=new

file(unicodetochinese(request.getparameter("path"))+unicodetochinese(request.getparameter("file")));

if(fileedit.exists())

{

//文件编辑操作,实际就是在修改文件内容以后,再于页面上用一个textarea 显示文件的内容,继续来做编辑或者

查看修改的效果

if(!(request.getparameter("filedata")==null))

{

try{

printwriter pwedit =null;

pwedit=new printwriter(new

fileoutputstream(unicodetochinese(request.getparameter("path"))+unicodetochinese(request.getparameter("file"))));

pwedit.println(unicodetochinese(request.getparameter("filedata")));

pwedit.close();

response.sendredirect(request.getrequesturi()+"?path="+

unicodetochinese(request.getparameter("path")) +"&file="+ unicodetochinese(request.getparameter("file")) +"&act=edit");

return;

}catch(exception e){

strerr="文件写入错误,请重新选择!";

}

}else{

strerr="缺少修改文件内容的参数,请重新选择!";

}

}else

//显示错误信息

strerr="你选择的文件不存在,请重新选择!";

}else{

strerr="你没有选择要编辑的文件,请重新选择!";

}

}else if(request.getparameter("act").equals("createf"))

{

//创建新的文件夹的页面显示

strstat="createf";

}else if(request.getparameter("act").equals("createfdo"))

{

//创建新的文件夹

string strfoldname=strdealpath+unicodetochinese(request.getparameter("foldname")).trim()+"\";

//out.println(strfoldname);

//out.close();

file filecreatef=new file(strfoldname);

if(!filecreatef.exists())

{

try{

filecreatef.mkdir();

response.sendredirect(request.getrequesturi()+"?path="+strdealpath+"&act=show");

return;

}catch(exception e){

strerr="创建新文件夹失败!";

}

}

else

{

strerr="指定的文件夹名称和现有的文件夹名称重复,请重新指定一个新的文件夹名称!";

}

}else if(request.getparameter("act").equals("delfolddo"))

{

//删除操作

try{

string strfiledelf=strdealpath+unicodetochinese(request.getparameter("fold"))+"\";

file filedelf=new file(strfiledelf);

if(filedelf.exists()){

file[] filearrcheck=filedelf.listfiles();

if(!(filearrcheck.length>0))

{

filedelf.delete();

response.sendredirect(request.getrequesturi()+"?path="+strdealpath+"&act=show");

return;

}else

{

strerr="文件夹下面还包含着文件,请把文件都删除,再删除文件夹";

}

}else{

strerr="要删除的文件夹不存在,请重新选择";

}

}catch(exception e)

{

strerr="文件夹删除操作错误!";

}

}else if(request.getparameter("act").equals("renamefold"))

{

strstat="renamefold";

}else if(request.getparameter("act").equals("renamefolddo"))

{

//文件夹更名操作

//根据参数判断是否对于文件夹名称有更改动作发生

if(request.getparameter("changedo").equals("true"))

{

//有文件名,更名发生

try{

string strfilerenamef=strdealpath+unicodetochinese(request.getparameter("fold"))+"\";

file filerenamef=new file(strfilerenamef);

string strfilerenametof=strdealpath+unicodetochinese(request.getparameter("newfoldname"))+"\";

file filerenametof=new file(strfilerenametof);

//判断更名的文件夹是否存在

if(filerenamef.exists()){

//判断新的文件夹名称是否与现存的文件夹重名

if(!filerenametof.exists())

{

filerenamef.renameto(filerenametof);

response.sendredirect(request.getrequesturi()+"?path="+strdealpath+"&act=show");

return;

}else

{

strerr="指定的文件夹名称和现有的文件夹名称重复,请重新指定一个文件夹名称!";

}

}else{

strerr="要更名的文件夹不存在,请重新选择";

}

}catch(exception e)

{

strerr="文件夹更名操作错误!";

}

}

}else if(request.getparameter("act").equals("renamefile"))

{

strstat="renamefile";

}else if(request.getparameter("act").equals("renamefiledo"))

{

//文件更名操作

//根据参数判断是否对于文件名称有更改动作发生

if(request.getparameter("changedo").equals("true"))

{

//有文件名,更名发生

try{

string strfilerenamefi=strdealpath+unicodetochinese(request.getparameter("file"));

file filerenamefi=new file(strfilerenamefi);

string strfilerenametofi=strdealpath+unicodetochinese(request.getparameter("newfilename"));

file filerenametofi=new file(strfilerenametofi);

//判断更名的文件是否存在

if(filerenamefi.exists()){

//判断新的文件名称是否与现存的文件重名

if(!filerenametofi.exists())

{

filerenamefi.renameto(filerenametofi);

response.sendredirect(request.getrequesturi()+"?path="+strdealpath+"&act=show");

return;

}else

{

strerr="指定的文件名称和现有的文件名称重复,请重新指定一个文件名称!";

}

}else{

strerr="要更名的文件不存在,请重新选择";

}

}catch(exception e)

{

strerr="文件更名操作错误!";

}

}

}else if(request.getparameter("act").equals("delfiledo"))

{

//删除操作

try{

string strfiledelfi=strdealpath+unicodetochinese(request.getparameter("file"));

file filedelfi=new file(strfiledelfi);

if(filedelfi.exists())

{

filedelfi.delete();

response.sendredirect(request.getrequesturi()+"?path="+strdealpath+"&act=show");

return;

}else{

strerr="要删除的文件不存在,请重新选择";

}

}catch(exception e)

{

strerr="文件删除操作错误!";

}

}else if(request.getparameter("act").equals("uploadfile"))

{

strstat="uploadfile";

}else if(request.getparameter("act").equals("uploadfiledo"))

{

%>

<jsp:usebean id="mysmartupload" scope="page" class="com.jspsmart.upload.smartupload" />

<%

//上传文件操作

mysmartupload.initialize(pagecontext);

mysmartupload.settotalmaxfilesize(1000000);

try {

mysmartupload.upload();

mysmartupload.save(strdealpath);

response.sendredirect(request.getrequesturi()+"?path="+strdealpath+"&act=show");

return;

} catch (exception e) {

strerr="文件上传出错,请检查是否超过1m 的文件大小限制!";

}

}

%>

<%

out.println(strstat);

%>

<html><head><title>directory listing for /</title>

<meta content="text/html; charset=utf-8" http-equiv=content-type>

<meta content="mshtml 5.00.2920.0" name=generator></head>

<body bgcolor=white>

<div align="center">

<table border=0 cellpadding=5 cellspacing=0 width="90%">

<tbody>

<tr>

<td align=left bgcolor=#000066 valign=bottom><font color=#ffffff face=宋体

size=4 roman? new ,?times><b>&nbsp;网站文件管理器</b></font></td>

<td align=right bgcolor=#000066 valign=bottom><font color=#ffffff face=宋体

size=4 roman? new ,?times><b>&nbsp;<strong><%=request.getcontextpath()%></strong></b></font></td>

</tr>

</tbody>

</table>

<table width="90%" border="0" cellspacing="0" cellpadding="5">

<tr>

<td><font size="2"><b>物理路径:</b><%=strdealpath%></font></td>

</tr>

</table>

<br>

<% if (strstat.equals("login")){%>

<table width="300" border="0" cellspacing="1" cellpadding="0" >

<tr>

<td height="200" valign="top" align="center">

<p align="center">

<table width="100%" border="0" cellspacing="1" cellpadding="5" bgcolor=#999999 class=a9px>

<tr>

<td bgcolor="#cccccc"><font size=+2>登录</font></td>

</tr>

<tr>

<td bgcolor="#ffffff" valign="top" align="center">

<table width="100%" border="0" cellspacing="0" cellpadding="0">

<form name=dataform method=post action=<%=request.getrequesturi()%>?act=login>

<tr>

<td width="100"><b><font size="-1">登录名:</font></b></td>

<td>

<input maxlength=16

name="username" value="">

</td>

</tr>

<tr>

<td width="100"><b><font size="-1">密码:</font></b></td>

<td>

<input class=stedit maxlength=16

name="userpass" value="">

</td>

</tr>

</form>

</table>

<br>

<table border=0 cellpadding=0 cellspacing=0>

<tbody>

<tr>

<td>

<input name=update onclick="javascript:if (checkform()==false);" type=button value="登 录">

</td>

<td>&nbsp;</td>

<td>&nbsp;</td>

</tr>

</tbody>

</table>

<br>

</td>

</tr>

</table>

</td>

</tr>

</table>

<% //错误信息显示

}else if(strerr!=""){

%>

<table width="90%" border="0" cellspacing="0" cellpadding="5">

<tr>

<td><font size=+2><strong>操作错误</strong></font></td>

</tr>

</table>

<table align=center cellpadding=5 cellspacing=0 width="90%">

<form name=dataform2

action="<%=request.getrequesturi()%>?path=<%=unicodetochinese(request.getparameter("path"))%>&fold=<%=unicodetochinese(reques

t.getparameter("fold"))%>&act=renamefolddo" method="post">

<tbody>

<tr bgcolor=#cccccc>

<td align=left bgcolor="#cccccc"><strong><font size="-1">错误原因:</font></strong></td>

</tr>

<tr>

<td align=left><tt><font color="red"><%=strerr%></font></tt>

</td>

</tr>

<tr>

<td bgcolor=#cccccc align="center"><tt>[ <a href="javascript:history.go(-1);">返回操作</a> ]</tt>&nbsp;&nbsp;<tt>[ <a

href="<%=request.getrequesturi()%>?path=<%=unicodetochinese(request.getparameter("path"))%>&act=show">返回目录</a>

]<input type=hidden name="changedo" value="false"></tt> </td>

</tr>

</tbody>

</form>

</table>

<%

}else if(strstat.equals("show")){

//正常显示页面

%>

<table width="90%" border="0" cellspacing="0" cellpadding="5">

<tr>

<td><font size=+2><strong>目录列表:</strong></font></td>

</tr>

</table>

<table align=center cellpadding=5 cellspacing=0 width="90%">

<tbody>

<tr bgcolor=#cccccc>

<td align=left><font size=+1><strong><font size="-1">名称</font></strong></font><tt>(单击进入相应目录)</tt></td>

<td align=center><font size=+1><strong><font size="-1">修改时间</font></strong></font></td>

<td align=center><b><font size="-1">重命名</font></b></td>

<td align=center><b><font size="-1">删除</font></b></td>

</tr>

<%

//显示表格行的初始颜色

string bgcolor="";

//如果不是根目录,则显示一个回到上层目录的连接

if(!(strdealpath.equals(strsyspath))){%>

<tr bgcolor=<%=bgcolor%>>

<td align=left >&nbsp;&nbsp;<tt><font color=#000066 face=wingdings

size=4>0</font><a title="单击进入上层目录"

href="<%=request.getrequesturi()%>?path=<%=(myfile.getparent())+"\"%>&act=show">上层目录</a></tt></td>

<td align=right>&nbsp;</td>

<td align=center>&nbsp;</td>

<td align=center>&nbsp;</td>

</tr>

<% }

for(int i=0 ; i<filearr.length ; i++){

//如果是文件夹则显示

if(filearr[i].isdirectory()){

//颜色隔行变换

bgcolor=bgcolor.equals("#eeeeee") ? "" : "#eeeeee";

%>

<tr bgcolor=<%=bgcolor%>>

<td align=left >&nbsp;&nbsp;<tt><font color=#000066 face=wingdings

size=4>0</font><a title="单击进入相应目录"

href="<%=request.getrequesturi()%>?path=<%=strdealpath+filearr[i].getname()+"\"%>&act=show"><%=filearr[i].getname()%></a></t

t></td>

<td align=center><tt><%=(new date(filearr[i].lastmodified()))%></tt></td>

<td align=center><tt><a

href="<%=request.getrequesturi()%>?path=<%=strdealpath%>&fold=<%=filearr[i].getname()%>&act=renamefold">重命名</a></tt></td>

<form name="dataformfold<%=i%>" method="post"

action="<%=request.getrequesturi()%>?path=<%=strdealpath%>&fold=<%=filearr[i].getname()%>&act=delfolddo"><td

align=center><tt><a href="javascript:if(confirm(确实要删除该文件夹,所有的内容将不能继续使用?

)){window.dataformfold<%=i%>.submit();}">删除</a></tt></td></form>

</tr>

<% }

} %>

<tr align="center">

<td bgcolor=#cccccc colspan=4><tt>[ <a href="<%=request.getrequesturi()%>?path=<%=strdealpath%>&act=createf">新建文件夹

</a>

]</tt></td>

</tr>

</tbody>

</table>

<table width="90%" border="0" cellspacing="0" cellpadding="5">

<tr>

<td><font size=+2><strong>文件列表:</strong></font></td>

</tr>

</table>

<table align=center cellpadding=5 cellspacing=0 width="90%">

<tbody>

<tr bgcolor=#cccccc>

<td align=left><font size=+1><strong><font size="-1">名称</font></strong></font><tt>(单击编辑相应文件)</tt></td>

<td align=center><font size=+1><strong><font size="-1">大小</font></strong></font></td>

<td align=center><font size=+1><strong><font size="-1">修改时间</font></strong></font></td>

<td align=center><b><font size="-1">重命名</font></b></td>

<td align=center><b><font size="-1">删除</font></b></td>

</tr>

<%

bgcolor="#eeeeee";

if(filearr.length!=0){

for(int i=0 ; i<filearr.length ; i++){

//如果是文件则显示

if(filearr[i].isfile()){

bgcolor=bgcolor.equals("#eeeeee") ? "" : "#eeeeee";

%>

<tr bgcolor=<%=bgcolor%>>

<td align=left >&nbsp;&nbsp; <tt><font color=#000066 face=wingdings

size=4>3</font><a title="单击编辑相应文件"

href="<%=request.getrequesturi()%>?path=<%=strdealpath%>&file=<%=filearr[i].getname()%>&act=edit"><%=filearr[i].getname()%></

a></tt></td>

<td align=center><tt><%=filearr[i].length()%></tt></td>

<td align=center><tt><%=(new date(filearr[i].lastmodified()))%></tt></td>

<td align=center><tt><a

href="<%=request.getrequesturi()%>?path=<%=strdealpath%>&file=<%=filearr[i].getname()%>&act=renamefile">重命名</a></tt></td>

<form name="dataformfile<%=i%>" method="post"

action="<%=request.getrequesturi()%>?path=<%=strdealpath%>&file=<%=filearr[i].getname()%>&act=delfiledo"><td

align=center><tt><a href="javascript:if(confirm(确实要删除该文件,内容将不能继续使用?

)){window.dataformfile<%=i%>.submit();}">删除</a></tt></td></form>

</tr>

<% }

}

}else {%>

<tr>

<td align=left >&nbsp;&nbsp; <tt>没有文件</tt></td>

<td align=right>&nbsp;</td>

<td align=right>&nbsp;</td>

<td align=center>&nbsp;</td>

<td align=center>&nbsp;</td>

</tr>

<%}%>

<tr align="center">

<td bgcolor=#cccccc colspan=5><tt>[ <a href="<%=request.getrequesturi()%>?path=<%=strdealpath%>&act=uploadfile">上传文

件</a> ]</tt></td>

</tr>

</tbody>

</table>

<%

//正常显示状态结束

}else if(strstat.equals("edit")){

//文件编辑状态

bufferedreader bufreadin=new bufferedreader(new

filereader(unicodetochinese(request.getparameter("path"))+unicodetochinese(request.getparameter("file"))));

string strcontext="";

string strreadline="";

%>

<table width="90%" border="0" cellspacing="0" cellpadding="5">

<tr>

<td><font size=+2><strong>编辑文件:</strong></font></td>

</tr>

</table>

<table align=center cellpadding=5 cellspacing=0 width="90%">

<form name=dataform

action="<%=request.getrequesturi()%>?path=<%=unicodetochinese(request.getparameter("path"))%>&file=<%=unicodetochinese(reques

t.getparameter("file"))%>&act=editdo" method="post">

<tbody>

<tr bgcolor=#cccccc>

<td align=left><font size=+1><strong><font size="-1">文件名称</font></strong></font><tt><font color=#000066

face=wingdings

size=4>3</font><%=(unicodetochinese(request.getparameter("path"))+unicodetochinese(request.getparameter("file")))%></tt></td>

</tr>

<tr>

<td align=center><textarea name="filedata" rows=18 cols=70 wrap=""off""><%

while((strreadline=bufreadin.readline())!=null)

out.println(strreadline);

bufreadin.close();%></textarea></td>

</tr>

<tr>

<td bgcolor=#cccccc align="center">

<tt>[ <a href="javascript:window.dataform.submit();">提交内容</a> ]</tt>&nbsp;&nbsp;<tt>[ <a

href="<%=request.getrequesturi()%>?path=<%=unicodetochinese(request.getparameter("path"))%>&act=show">返回目录</a> ]</tt>

</td>

</tr>

</tbody>

</form>

</table>

<%

}else if(strstat.equals("createf")){

%>

<table width="90%" border="0" cellspacing="0" cellpadding="5">

<tr>

<td><font size=+2><strong>创建文件夹:</strong></font></td>

</tr>

</table>

<table align=center cellpadding=5 cellspacing=0 width="90%">

<form name=dataform

action="<%=request.getrequesturi()%>?path=<%=unicodetochinese(request.getparameter("path"))%>&act=createfdo" method="post">

<tbody>

<tr bgcolor=#cccccc>

<td align=left><font size=+1><strong><font size="-1">你要创建的文件夹在</font></strong></font><font color=#000066

face=wingdings

size=4>0</font><tt><%=(unicodetochinese(request.getparameter("path")))%></tt><font size=+1><strong><font size="-1">下

</font></strong></font></td>

</tr>

<tr>

<td align=left>

<tt>新建文件夹名称:</tt><input type=text name=foldname value="" maxlength="50" size="50">

</td>

</tr>

<tr>

<td bgcolor=#cccccc align="center"> <tt>[ <a href="javascript:if (checkform()==false);">提交内容</a>

]</tt>&nbsp;&nbsp;<tt>[ <a

href="<%=request.getrequesturi()%>?path=<%=unicodetochinese(request.getparameter("path"))%>&act=show">返回目录</a>

]</tt> </td>

</tr>

</tbody>

</form>

</table>

<%

}else if(strstat.equals("renamefold"))

{ %>

<table width="90%" border="0" cellspacing="0" cellpadding="5">

<tr>

<td><font size=+2><strong>重命名文件夹:</strong></font></td>

</tr>

</table>

<table align=center cellpadding=5 cellspacing=0 width="90%">

<form name=dataform2

action="<%=request.getrequesturi()%>?path=<%=unicodetochinese(request.getparameter("path"))%>&fold=<%=unicodetochinese(reques

t.getparameter("fold"))%>&act=renamefolddo" method="post">

<tbody>

<tr bgcolor=#cccccc>

<td align=left><font size=+1><strong><font size="-1">你要重命名的文件夹</font></strong></font><font color=#000066

face=wingdings

size=4>0</font><tt><%=(unicodetochinese(request.getparameter("path"))+unicodetochinese(request.getparameter("fold"))+"\")%><

/tt></td>

</tr>

<tr>

<td align=left> <tt>重命名的文件夹名称:</tt>

<input type=text name=newfoldname value="<%=unicodetochinese(request.getparameter("fold"))%>" maxlength="50"

size="50">

</td>

</tr>

<tr>

<td bgcolor=#cccccc align="center"> <tt>[ <a href="javascript:if (checkform2()==false);">提交内容</a>

]</tt>&nbsp;&nbsp;<tt>[ <a

href="<%=request.getrequesturi()%>?path=<%=unicodetochinese(request.getparameter("path"))%>&act=show">返回目录</a>

]<input type=hidden name="changedo" value="false"></tt> </td>

</tr>

</tbody>

</form>

</table>

<%

}else if(strstat.equals("renamefile"))

{%>

<table width="90%" border="0" cellspacing="0" cellpadding="5">

<tr>

<td><font size=+2><strong>重命名文件:</strong></font></td>

</tr>

</table>

<table align=center cellpadding=5 cellspacing=0 width="90%">

<form name=dataform3

action="<%=request.getrequesturi()%>?path=<%=unicodetochinese(request.getparameter("path"))%>&file=<%=unicodetochinese(reques

t.getparameter("file"))%>&act=renamefiledo" method="post">

<tbody>

<tr bgcolor=#cccccc>

<td align=left><font size=+1><strong><font size="-1">你要重命名的文件</font></strong></font><font color=#000066

face=wingdings

size=4>3</font><tt><%=(unicodetochinese(request.getparameter("path"))+unicodetochinese(request.getparameter("file")))%></tt><

/td>

</tr>

<tr>

<td align=left> <tt>重命名的文件名称:</tt>

<input type=text name=newfilename value="<%=unicodetochinese(request.getparameter("file"))%>" maxlength="50"

size="50">

</td>

</tr>

<tr>

<td bgcolor=#cccccc align="center"> <tt>[ <a href="javascript:if (checkform3()==false);">提交内容</a>

]</tt>&nbsp;&nbsp;<tt>[ <a

href="<%=request.getrequesturi()%>?path=<%=unicodetochinese(request.getparameter("path"))%>&act=show">返回目录</a>

]

<input type=hidden name="changedo" value="false">

</tt> </td>

</tr>

</tbody>

</form>

</table>

<%

}else if(strstat.equals("uploadfile")){

%>

<table width="90%" border="0" cellspacing="0" cellpadding="5">

<tr>

<td><font size=+2><strong>上传文件:</strong></font></td>

</tr>

</table>

<table align=center cellpadding=5 cellspacing=0 width="90%">

<form name=dataform4

action="<%=request.getrequesturi()%>?path=<%=unicodetochinese(request.getparameter("path"))%>&act=uploadfiledo" method="post"

enctype="multipart/form-data">

<tbody>

<tr bgcolor=#cccccc>

<td align=left><font size=+1><strong><font size="-1">你要上传的文件在</font></strong></font><font color=#000066

face=wingdings

size=4>0</font><tt><%=(unicodetochinese(request.getparameter("path")))%></tt><font size=+1><strong><font size="-1">下

</font></strong></font></td>

</tr>

<tr>

<td align=left> <tt>选择上传的文件:</tt>

<input type="file" name="filename" size="30"></td>

</tr>

<tr>

<td bgcolor=#cccccc align="center"> <tt>[ <a href="javascript:if (checkform4()==false);">提交内容</a>

]</tt>&nbsp;&nbsp;<tt>[ <a

href="<%=request.getrequesturi()%>?path=<%=unicodetochinese(request.getparameter("path"))%>&act=show">返回目录</a>

]

</tt> </td>

</tr>

</tbody>

</form>

</table>

<%

}

%>

<br>

<br>

<hr>

<tt>&copy;版权所有:joard?ast  版本: 简体中文1.00</tt>

<br><tt>任何意见或建议请联络:<a href="mailto:ebony_mzb@hotmail.com"><font color=red>ebony_mzb@hotmail.com</font></a></tt>

</div>

</body></html>

<script language=javascript>

<!–

<%

//根据参数不同,显示不同的检测参数的函数

if(strstat.equals("login")) {%>

function checkform()

{

var checkblank = /^(s*|( )|(.))*$/;

if (checkblank.test(dataform.username.value))

{

alert("登录名不能为空!");

return false;

}

if (checkblank.test(dataform.userpass.value))

{

alert("密码不能为空!");

return false;

}

window.dataform.submit();

}

<%}else if(strstat.equals("createfold")) {%>

function checkform()

{

var checkblank = /^(s*|( )|(.))*$/;

if (checkblank.test(dataform.foldname.value))

{

alert("新建文件夹名称不能为空!");

dataform.foldname.focus();

return false;

}

var special_str = "\/:*?"><|";

for(i=0;i<(dataform.foldname.value).length;i++)

{

if (special_str.indexof((dataform.foldname.value).charat(i)) !=-1)

{

alert("文件夹名称不能含有如下字符\/:*?"><|");

dataform.foldname.focus();

return false;

}

}

window.dataform.submit();

}

<%}else if(strstat.equals("renamefold")) {%>

function checkform2()

{

var checkblank = /^(s*|( )|(.))*$/;

if (checkblank.test(dataform2.newfoldname.value))

{

alert("重命名的文件夹名称不能为空!");

dataform2.newfoldname.focus();

return false;

}

var special_str = "\/:*?"><|";

for(i=0;i<(dataform2.newfoldname.value).length;i++)

{

if (special_str.indexof((dataform2.newfoldname.value).charat(i)) !=-1)

{

alert("文件夹名称不能含有如下字符\/:*?"><|");

dataform2.newfoldname.focus();

return false;

}

}

//如果文件更名后和原文件名不同,则标示一个参数,表明确实有更名动作发生

if(dataform2.newfoldname.value!="<%=unicodetochinese(request.getparameter("fold"))%>")

{

window.dataform2.changedo.value="true";

}

else

{

alert("请输入一个新的文件夹名称!");

dataform2.newfoldname.focus();

return false;

}

window.dataform2.submit();

}

<%}else if(strstat.equals("renamefile"))

{%>

function checkform3()

{

var checkblank = /^(s*|( )|(.))*$/;

if (checkblank.test(dataform3.newfilename.value))

{

alert("重命名的文件夹名称不能为空!");

dataform3.newfilename.focus();

return false;

}

var special_str = "\/:*?"><|";

for(i=0;i<(dataform3.newfilename.value).length;i++)

{

if (special_str.indexof((dataform3.newfilename.value).charat(i)) !=-1)

{

alert("文件名称不能含有如下字符\/:*?"><|");

dataform3.newfilename.focus();

return false;

}

}

//如果文件更名后和原文件名不同,则标示一个参数,表明确实有更名动作发生

if(dataform3.newfilename.value!="<%=unicodetochinese(request.getparameter("file"))%>")

{

window.dataform3.changedo.value="true";

}

else

{

alert("请输入一个新的文件名称!");

dataform3.newfilename.focus();

return false;

}

window.dataform3.submit();

}

<%}else if(strstat.equals("uploadfile")){%>

function checkform4()

{

var checkblank = /^(s*|( )|(.))*$/;

if (checkblank.test(dataform4.filename.value))

{

alert("重命名的文件夹名称不能为空!");

dataform4.filename.focus();

return false;

}

window.dataform4.submit();

}

<%}%>

//–>

</script>

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » JSP单页面网站文件管理器-JSP教程,Jsp/Servlet
分享到: 更多 (0)

相关推荐

  • 暂无文章