<%@ page 
   language="java"
   contentType="text/html; charset=big5"
   pageEncoding="BIG5"
  import="java.util.*, java.io.*, java.net.URLEncoder" 
 %><%
   String aa=getServletContext().getRealPath("/")+"upload\\";
   String filename=request.getParameter("filename"); 
   String src_fname = aa+filename; 
   String dst_fname = URLEncoder.encode(filename); 
   request.setCharacterEncoding("big5");   
   response.setContentType("application/octet-stream; charset=iso-8859-1");
   response.setHeader("Content-disposition", "attachment; filename=\"" + dst_fname + "\"");  
   FileInputStream fis = null; 
   int byteRead; 
   try {
     fis = new FileInputStream(src_fname);
     while ((byteRead = fis.read()) != -1) {
       out.write(byteRead);
    }
     out.flush();
   } 
   catch (Exception e) {
     out.clearBuffer();
    response.setContentType("text/html; charset=big5");
     response.setHeader("Content-disposition", "inline");
     out.println("<HTML><BODY><P>");
     out.println(e.toString());
     out.println("</P></BODY></HTML>");    
  } 
   if (fis != null) {
     fis.close();
   }
   return; // 避免下面多按了 Enter 键而输出多余的换行字元.
 %>