电脑桌面
添加小米粒文库到电脑桌面
安装后可以在桌面快捷访问

jsp如何实现下载文件的功能

jsp如何实现下载文件的功能_第1页
1/6
jsp如何实现下载文件的功能_第2页
2/6
jsp如何实现下载文件的功能_第3页
3/6
jsp 如何实现下载文件的功能 第一步:创建 Servlet 第二步:写代码 public class FielDownLoad extends HttpServlet { /** * Constructor of the object. */ public FielDownLoad() { super(); } /** * Destruction of the servlet.
*/ public void destroy() { super.destroy(); // Just puts "destroy" string in log // Put your code here } /** * The doGet method of the servlet.
* * This method is called when a form has its tag value method equals to get. * * @param request the request send by the client to the server * @param response the response send by the server to the client * @throws ServletException if an error occurred * @throws IOException if an error occurred */ public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { doPost(request, response); } /** * The doPost method of the servlet.
* * This method is called when a form has its tag value method equals to post. * * @param request the request send by the client to the server * @param response the response send by the server to the client * @throws ServletException if an error occurred * @throws IOException if an error occurred */ public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String filename = request.getParameter("file_name"); if (filename == null) filename = ""; filename = filename.trim(); InputStream inStream = null; String attchname = ""; byte[] b = new byte[100]; int len = 0; try { attchname = getAttachName(filename); //取得附件的名称 filename = getRealName(request, filename); //取得附件的全路径 if (filename == null) { response.setContentType("text/html; charset=GBK"); response.getWriter().print("文件不存...

1、当您付费下载文档后,您只拥有了使用权限,并不意味着购买了版权,文档只能用于自身使用,不得用于其他商业用途(如 [转卖]进行直接盈利或[编辑后售卖]进行间接盈利)。
2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。
3、如文档内容存在违规,或者侵犯商业秘密、侵犯著作权等,请点击“违规举报”。

碎片内容

jsp如何实现下载文件的功能

确认删除?
VIP
微信客服
  • 扫码咨询
会员Q群
  • 会员专属群点击这里加入QQ群
客服邮箱
回到顶部