资讯   |   开发   |   选机中心   |   产品大全 | IBM | 惠普 | 联想 | 戴尔 | 苹果 | 神舟
更多: | 华硕 | 明基 | 方正 | 紫光 | TCL | 夏新 | 联宝 | 宏碁 | 七喜 | 长城 | 清华同方 | 海尔 | 三星 | 东芝 | 索尼 | 富士通 | LG | 技术 | ddnoon
当前位置:笔记本 > 软件开发 >
Advertisement
文章正文

关于读PDF的问题~~~急在线等

类型:转载   责任编辑:asp.net   日期:2007/05/23


热门软件下载:


   

小生我写了一个用servlet显示FTP上的文档的程序,现在有些问题,就是在调用该servlet的时候出现的不是显示,是下载  
   
  请问各位大虾改怎么办啊~~~救命啊在~~~~  
   
   
      public     void     doGet(HttpServletRequest     request,     HttpServletResponse     response)     throws     ServletException,     IOException     {      
                String     type=request.getParameter("type");      
                String     fileName=request.getParameter("fileName");      
     
                if(type.equals("doc")     ¦     ¦type.equals("DOC")){      
                                    content_type="application/vnd.ms-word";      
                                    type="doc";      
                                    }      
                        else     if(type.equals("pdf")     ¦     ¦type.equals("PDF")){      
                                    content_type="application/pdf";      
                                    type="pdf";      
                                    }      
                String     file=fileName+"."+type;      
                response.setContentType(content_type);      
                ServletOutputStream     out=response.getOutputStream();      
                FtpClient     ftp=new     FtpClient(FTP_NAME);      
                ftp.login("username","password");      
                ftp.cd("pdf");      
                try{      
                        ftp.binary();      
                        TelnetInputStream     in=ftp.get(fileName+"."+type);      
     
                        byte[]     b=new     byte[1024];      
                        int     len=0;      
                        while((len     =     in.read(b))     !=     -1){      
                                    out.write(b,0,len);      
                                    out.flush();      
                        }      
                out.close();      
                if(in!=null){      
                in.close();}      
        }catch(Exception     e){      
                System.err.println(e);      
        }

网友回答:

发表者:tigeryu

加上这句话  
   
  response.setHeader("Content-disposition",   "inline");

发表者:dropship

这个我做过,我遇见的问题是,pdf可以直接显示,doc总是显示为下载,不知道你什么问题?

发表者:Tabalulu

配置问题  
  查找mime.properties文件,删除相关的mime配置


 

 
热门推荐笔记本: IBM笔记本
相关文章:
webmaster:popbb@126.com   最佳浏览:1024X768 MSIE
©2007 popbb.net All Rights Reserved