jsp,javaダウンロード添付ファイル


jspはwordをダウンロードして、excel
<iframe src="fileName" name="realName%" id="showFileId" width="100%" height="100%"></iframe>

src:ファイルパス
JAvaバックグラウンドで添付ファイルコードをダウンロード
 /**
    * @param response  response  
     * @param fullName         
     * @param disName          
     * @param downType       attachment(      ), file(  inline) 
     */
  File dbFile = new File(fullName);
  FileInputStream fileIn = new FileInputStream(dbFile);
    	            
  String contentType;
  contentType = "application/msword";
  response.setContentType(contentType);
  response.setHeader("Content-Disposition", " filename=report.xls");

  StringBuffer header = null;
  if (downType != null && !"".equals(downType)) {
     header = new StringBuffer(downType + "; filename=");                
   } else {
     header = new StringBuffer("file; filename=");
   }            
   //             ,        ISO8859_1   
    disName = new String(disName.getBytes("GBK"), "ISO8859_1");
   header.append(disName);
   response.setHeader("Content-Disposition", header.toString());
   byte[] buffer = new byte[1024 * 512];
   while (true) {
         int bytes = fileIn.read(buffer);
    	if (bytes == -1) {
    	      break;
    	}
       response.getOutputStream().write(buffer, 0, bytes);
   }
   response.getOutputStream().flush();
   response.getOutputStream().close();
   fileIn.close();
   } catch (Exception e) {
      e.printStackTrace();
   }