云题海 - 专业文章范例文档资料分享平台

当前位置:首页 > Linux下J2EE开发与运行环境搭建达到JSP程序可以访问数据库 - 图文

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

  • 62 次阅读
  • 3 次下载
  • 2025/5/2 13:40:49

上海商学院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=\+

  • 收藏
  • 违规举报
  • 版权认领
下载文档10.00 元 加入VIP免费下载
推荐下载
本文作者:...

共分享92篇相关文档

文档简介:

上海商学院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);// 设置允许

× 游客快捷下载通道(下载后可以自由复制和排版)
单篇付费下载
限时特价:10 元/份 原价:20元
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:fanwen365 QQ:370150219
Copyright © 云题海 All Rights Reserved. 苏ICP备16052595号-3 网站地图 客服QQ:370150219 邮箱:370150219@qq.com