方法很多,基本方法就是要把文件数据流搞到客户端了

解决方案 »

  1.   


    我的程序 如下:
    报错说已经打开一个word窗口,不能关闭word,是什么原因?String Sql= "SELECT MACCOUNT FROM JHYH_GWFJB where MDOCID='"+mdocId+"'and MCONTENTID='"+contentId+"'";
    //String Sql1="SELECT MCREATEID FROM JHYH_GWFJB where MDOCID='"+mdocId+"'and MCONTENTID='"+contentId+"'";
    try  
    {  
    ResultSet rs = DBMgr.executeQuery(sqlCon, Sql);
      System.out.println("CreatMisBlobSql="+Sql); 
       OutputStream  outFile=response.getOutputStream();     
     response.setContentType("application/msword"); 
         response.addHeader("content-type","application/msword"); 
                  //response.addHeader("Content-Disposition",  "attachment;  filename=\""  +  "Temp."+FileType  +  "\"");  
                 response.addHeader("Content-Disposition", "inline; filename=\"" + "Temp."+FileType + "\"");
       if  (rs.next())  
                   {  
                           InputStream  inFile  =  rs.getBinaryStream(1);  
                           int  length=0;  
                           int  STREAM_SIZE  =  1000000;  
                           byte[]  buffer  =  new  byte[STREAM_SIZE];  
                           while  ((length  =  inFile.read(buffer))  !=  -1)  
                           {  
                                   System.out.println("readed  lenth  =  "+length);  
                                   outFile.write(buffer,0,length)  ;  
       System.out.println("write over!!!!!!!!!!");
    }    
                   }  
                           rs.close();  
        System.out.println("111111111");
                           outFile.close(); 
        System.out.println("222222222222"); 
           }  catch(Exception  e)  
    {  
           e.printStackTrace();  
    }
    finally
    {    sqlCon.close();}
    System.out.println("3333333333333333333");%>
    现在报错说:
      

  2.   

    现在程序好象运行了两次,3333333333333333333打出来两次,我也不知道是什么原因?