如何用链接的方式打开一个pdg文件 pdg是超星阅读器的专有文件,先安装一个超星阅读器,至于能否被IE支持就要试试了,不支持的话会提示下载而不会直接打开。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 如果是pdg文件作为二进制文件存在于数据库中,可以用如下的程序段打开:当然你要传一个该条记录的ID过来。String id = request.getParameter("id"); String sql = "select * from archive_attach where attach_id='" + id + "'"; Archive ar = new Archive(true); ResultSet rs = null; rs = ar.queryOracle(sql); oracle.sql.BLOB attachLob = null; byte buf[] = null; String fileName = ""; try { if(rs.next()) { fileName = rs.getString("attach_filename"); System.out.println("====== in the show_attach.jsp : fileName: " + fileName); attachLob = (oracle.sql.BLOB)rs.getBlob("attach_content"); buf = attachLob.getBytes((long)1,(int)attachLob.length()); response.setContentType("application/x-msdownload"); response.setHeader("Content-Disposition", "attachment; filename=" + fileName); //将缓冲区的输入输出到页面 response.getOutputStream().write(buf); //输入完毕,清除缓冲 response.getOutputStream().flush(); response.getOutputStream().close(); } ar.closeConnection(); }catch(Exception e) { ar.closeConnection(); System.out.println("error in show_attach.jsp: " + e.getMessage()); } 修改tomcat/conf/web.xml文件,增加<mime-mapping> <extension>pdf</extension> <mime-type>application/x-msdownload</mime-type></mime-mapping> 不是存在数据库中,只是把文件的路径存在数据库中。如果用的是weblogic服务器呢? jsp中关于查询mysql数据库的一个问题。 跳转问题 session和验证码不同步的问题,高手指点下, 如何用javascirpt对数据进行CHECK来决定表单是否提交 在html里输出document.write内的类容 b/s系统用jni能否控制客户端的外设(读卡器) 54260683 java web 高级交流群。欢迎大家加入 怎么将一个5M左右的byte[]从ServletOutputStream输出? 怎样用table标签从数据库里面取值并在页面一条条显 gwt问题 求助在线编辑组件问题 遇到乱码了:请问gbk 于gb2312实际应用中有何异同?除了
String id = request.getParameter("id");
String sql = "select * from archive_attach where attach_id='" + id + "'";
Archive ar = new Archive(true);
ResultSet rs = null;
rs = ar.queryOracle(sql); oracle.sql.BLOB attachLob = null;
byte buf[] = null;
String fileName = ""; try {
if(rs.next()) {
fileName = rs.getString("attach_filename");
System.out.println("====== in the show_attach.jsp : fileName: " + fileName);
attachLob = (oracle.sql.BLOB)rs.getBlob("attach_content");
buf = attachLob.getBytes((long)1,(int)attachLob.length());
response.setContentType("application/x-msdownload");
response.setHeader("Content-Disposition", "attachment; filename=" + fileName); //将缓冲区的输入输出到页面
response.getOutputStream().write(buf);
//输入完毕,清除缓冲
response.getOutputStream().flush();
response.getOutputStream().close();
}
ar.closeConnection();
}catch(Exception e) {
ar.closeConnection();
System.out.println("error in show_attach.jsp: " + e.getMessage());
}
<mime-mapping>
<extension>pdf</extension>
<mime-type>application/x-msdownload</mime-type>
</mime-mapping>
如果用的是weblogic服务器呢?