且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Java服务器端发送文件与恢复支持?

更新时间:2023-11-27 21:55:58

支持可下载的下载有两个部分:





如果您提供静态资源,***的办法是使用代理服务器,如Apache,来处理下载。如果一个代理服务器不是一个选项,那么你可以找到一个与应用服务器捆绑在一起的Servlet;例如,Tomcat具有 DefaultServlet 。此选项的缺点是它在应用程序和应用程序服务器之间创建了一个严重的依赖关系,这可能是不可接受的。



如果您决定自行滚动我推荐请查看Apache的 HTTP组件。这是一个很好的API,可以使HTTP请求和响应变得更加容易。


I am trying to allow my java server to transfer a file where a web browser can download.

However, I want the browser if they pause and resume the file transfer to work and not start the download all over again.

Anyone know java code for the server side to fix this issue?

There are two parts to supporting resumable downloads:

If you're serving up a static resource your best bet is to use a proxy server, like Apache, to handle the download. If a proxy server isn't an option then you can probably find a Servlet that is bundled with your app server; for example, Tomcat has as DefaultServlet. The downside to this option is that it creates a hard dependency between your application and the application server, which may not be acceptable.

If you decide to roll your own I recommend taking a look at Apache's HTTP Components. It's a nice API that makes working with HTTP requests and responses much easier.