0514-86177077
9:00-17:00(工作日)
%@page import="java.util.*"%>%@page import="java.io.*"%>%@page import="java.net.*"%>% String filename = ""; if (request.getParameter("file") != null) { filename = request.getParameter("file"); } response.setContentType("application/msword"); response.setHeader("Content-disposition","attachment; filename="+filename); BufferedInputStream bis = null; BufferedOutputStream bos = null; try { bis = new BufferedInputStream(new FileInputStream(getServletContext().getRealPath("" + filename))); bos = new BufferedOutputStream(response.getOutputStream()); byte[] buff = new byte[2048]; int bytesRead; while(-1 != (bytesRead = bis.read(buff, 0, buff.length))) { bos.write(buff,0,bytesRead); } } catch(final IOException e) { System.out.println ( "出现IOException." + e ); } finally { if (bis != null) bis.close(); if (bos != null) bos.close(); } return;%>
标签:绍兴 北海 玉树 肇庆 潮州 广元 吴忠 保定
上一篇:jsp连接数据库大全
下一篇:几则JSP入门知识总结