js| Server
A little problem
JSP deletes files on the server
It's been debugged for a long time.
The results show that the problem of test absolute path
It's done now. '
<%@ page contenttype= "text/html; charset=gb2312 "language=" java "import=" java.sql.* "errorpage=" "%>"
<%@ page import= "java.io.*"%>
<%
String Path = Application.getrealpath ("/"); Get the current absolute path
String url= path+ "at.jpg"; Get absolute file name
Out.println (URL);
Out.println ("<br>File f=new file (URL);
Boolean flag=false;
if (f.exists ()) ... {//If file exists Delete if file does not exist print out file not found
Flag=f.delete ();
if (flag)
... {
OUT.PRINTLN ("Success");
}
Else
... {
Out.println ("file can not delete");
}
}
Else
OUT.PRINTLN ("File not exists");
%>
Environment Red Hat Enterprise Linux as Release 3 (Taroon)
Kernel 2.4.21-4.el on a i686
Tomcat:apache tomcat/5.5.20