第一范文网 - 专业文章范例文档资料分享平台

Linux下J2EE开发与运行环境搭建达到JSP程序可以访问数据库 - 图文

来源:用户分享 时间:2025/5/23 13:07:11 本文由loading 分享 下载这篇文档手机版
说明:文章内容仅供预览,部分内容可能不全,需要完整文档或者需要复制内容,请下载word后使用。下载word有问题请添加微信号:xxxxxxx或QQ:xxxxxx 处理(尽可能给您提供完整文档),感谢您的支持与谅解。

上海商学院Linux操作系统课程设计报告

public void destroy() { super.destroy(); }

public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

SmartUpload andy = new SmartUpload(); andy.initialize(config, request, response); try {

andy.setDenyPhysicalPath(true); // 拒绝物理路径

andy.setMaxFileSize(5000000);// 设置允许上传文件最大为50000bytes

andy.setTotalMaxFileSize(50000000);// 一次上传文件大小最多不超过5000000bytes andy.upload();

for (int i = 0; i < andy.getFiles().getCount(); i++) {

com.jspsmart.upload.File myfile = andy.getFiles().getFile(i); response.setContentType(\ PrintWriter out = response.getWriter();

String UpId= andy.getRequest().getParameter(\

String UpName= andy.getRequest().getParameter(\

String CourseName= andy.getRequest().getParameter(\ String FileName=myfile.getFileName(); andy.save(\

out.print(\上传者编号: \ out.print(\上传者姓名: \ out.print(\文件名: \ out.print(\课程名: \ out.print(\文件上传成功!\ andy dosql=new andy();

dosql.addfile(UpId,UpName,CourseName,FileName);

response.sendRedirect(\如果要显示上传情况,可以将此句注释掉 out.close(); }

} catch (Exception e) { e.printStackTrace();

- 21 -

Linux下J2EE开发与运行环境搭建达到JSP程序可以访问数据库

} }

public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { doPost(request, response); }

public void init(ServletConfig config) throws ServletException { this.config = config; } }

6.6.2.1 下载代码

DownloadServlet.java package servlet; import java.io.*;

import javax.servlet.*; import javax.servlet.http.*; import com.jspsmart.upload.*;

public class DownloadServlet extends HttpServlet { private ServletConfig config;

public DownloadServlet() { super(); }

public void destroy() { super.destroy(); }

public void doPost(HttpServletRequest request, HttpServletResponse response)

- 22 -

上海商学院Linux操作系统课程设计报告

throws ServletException, IOException {

SmartUpload andy = new SmartUpload(); //新建一个SmartUpload对象 andy.initialize(config, request, response); try {

response.setContentType(\ request.setCharacterEncoding(\

String name=new String(request.getParameter(\

andy.setContentDisposition(null);//如果要实现单击在浏览器打开,注释该即可.

andy.downloadFile(\下载目录

} catch (SmartUploadException e) { e.printStackTrace(); } }

public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { doPost(request, response); }

public void init(ServletConfig config) throws ServletException { this.config = config; } }

6.6.2.3 删除功能代码

delete.jsp

<%@ page language=\

- 23 -

Linux下J2EE开发与运行环境搭建达到JSP程序可以访问数据库

<% andy dosql=new andy();

String FileName=request.getParameter(\ response.setHeader(\\java.net.URLEncoder.encode(FileName, \ if(FileName!=null)

dosql.deletefileByFileName(FileName); response.sendRedirect(\ %>

- 24 -

filename=\+

Linux下J2EE开发与运行环境搭建达到JSP程序可以访问数据库 - 图文.doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.diyifanwen.net/c4u15b5lnv29ersa9r17g_7.html(转载请注明文章来源)
热门推荐
Copyright © 2012-2023 第一范文网 版权所有 免责声明 | 联系我们
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:xxxxxx 邮箱:xxxxxx@qq.com
渝ICP备2023013149号
Top