public Hashtable<String, Object> download(String fileid, String basePath,
Hashtable<String, Object> hsTmp, HttpServletRequest request,
HttpServletResponse response) {

TBmpMtannex tbx1 = new TBmpMtannex();//
tbx1 = (TBmpMtannex) (daoTool
.find("from TBmpMtannex as a where a.MFileId='" + fileid + "'"))
.get(0);//
// HttpServlet servlet = null;
String path = tbx1.getMSpace();//
// String path
// =servlet.getServletContext().getRealPath("")+"\\upload\\";
        String fileName = tbx1.getMFileName();//
fileName = fileName.substring(fileName.indexOf("=") + 1);//
String filePath = path;//
String file = filePath + "/" + fileName;//
System.out.println(file);//
File fl=new File(file);//
if(!fl.exists()){//
response.setContentType("text/html");//
PrintWriter out;//
try {
out = response.getWriter();//
out.write("<script language='javascript'>alert('对不起,文件不存在!');</script>");//
out.flush();//
out.close();//
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
FileInputStream fis = null;//
OutputStream os = null;//
byte[] bos = new byte[1024];//
int length = 0;//
try {
response.setContentType("application/x-msdownload");//
response.setHeader("Content-disposition", "attachment;filename="//
+ new String(fileName.getBytes("gb2312"), "iso8859-1"));//
fis = new FileInputStream(file);//
os = response.getOutputStream();//
while ((length = fis.read(bos)) != -1) {//
os.write(bos, 0, length);//
os.flush();//
}
} catch (Exception ex) {
ex.printStackTrace();
} finally {
try {
if (os != null)
os.close();//
if (fis != null)
fis.close();//
} catch (Exception ex) {
ex.printStackTrace();
}
} return hsTmp;
}
上面是下载的实现类  当下载失败后在JSP页面弹出这个框,点确定后不回跳列表页面out.write("<script language='javascript'>alert('对不起,文件不存在!');</script>");//