【发布时间】:2016-01-09 08:10:13
【问题描述】:
什么是更好的方法来开发 FTP 看起来像如下所示的应用程序。
它将允许我项目中的人员下载我们使用的所有可安装软件,例如 IBM Websphere (1 GB)、eclipse (500 MB) 和许多其他单个大小从 2.5 GB 到 500 MB 不等的软件,托管在 Red Hat Linux 中
-
最好只安装 Apache HTTP Server 并将 DocumentRoot 设置为源目录,然后由 Apache 完成其余的工作吗?
DocumentRoot "/hosting/softwares"
-
使用 HTML/JSP 编写一个简单的 JAVA/J2EE Web 应用程序 以生成类似于上面的视图,并使用下面的伪代码 likw。但我认为在 JAVA 中读取如此大的文件并不是一个好主意。
File downloadFile = new File(filePath); FileInputStream inStream = new FileInputStream(downloadFile); response.setContentType(mimeType); response.setContentLength((int) downloadFile.length()); String headerKey = "Content-Disposition"; String headerValue = String.format("attachment; filename=\"%s\"", downloadFile.getName()); response.setHeader(headerKey, headerValue); // obtains response's output stream OutputStream outStream = response.getOutputStream(); byte[] buffer = new byte[4096]; int bytesRead = -1; while ((bytesRead = inStream.read(buffer)) != -1) { outStream.write(buffer, 0, bytesRead); } inStream.close(); outStream.close();
有没有其他方法可以完成这项工作,例如使用 HTML 或任何其他框架。
【问题讨论】:
-
这怎么跑题了?
标签: java html jsp web-applications