Download to determine whether the resource does not exist
String filesrcsss = "/uploadfiles /";
Filesrcsss = request. getrealpath (filesrcsss );
// Obtain the actual path D:/tomcat 5.0/webapps/studyteach/uploadfiles
If (! Pubfunc. Fileexists (Filesrcsss + "/" + inf1.getfilesrc ())){
System. Out. println (filesrcsss + "/" + inf1.getfilesrc ());
Out. println ("<SCRIPT> ");
Out. println ("alert ('This file does not exist! ');");
Out. println ("history. Go (-1 );");
Out. println ("</SCRIPT> ");
Return;
}
Out. println ("<SCRIPT> ");
Out. println ("document. Location = 'HTTP: //" + request. getservername () + "/uploadfiles/" + inf1.getfilesrc () + "';");
// Download
Out. println ("</SCRIPT> ");
Pubfunc. Java
Package com. jetsum. util;
Import java. Io .*;
Import java. util .*;
Import java. Lang .*;
public class pubfunc {
// whether the file exists
Public static Boolean fileexists (string filename) {
file F = new file (filename );
return F. isfile () & F. exists ();
}< BR >}< br>