简体   繁体   English

使用servlet从服务器将文件下载到客户端计算机上的指定位置

[英]Downloading file to a specified location on client machine from server using servlet

I am trying to download a file from the server to the client machine using Servlet. 我正在尝试使用Servlet将文件从服务器下载到客户端计算机。 I am reading a file from the server and trying to send that file to the client machine. 我正在从服务器读取文件,并尝试将该文件发送到客户端计算机。 Is there a way in servlet to send file from server to client? Servlet中是否有一种方法可以将文件从服务器发送到客户端? Or is it possible in servlets to transfer a file from the server to a location specified by the client? 还是在Servlet中将文件从服务器传输到客户端指定的位置?

The client is responsible to handle the response it gets from the server in any way it sees fit. 客户端负责以其认为合适的方式处理从服务器获得的响应。 It can save the response data, it can ignore it, it can do anything it wants. 它可以保存响应数据,可以忽略它,可以执行任何所需的操作。 The client is the client. 客户就是客户。

So, to answer your question, no the server has and must not have any way to specify how the client handles the response. 因此,要回答你的问题, 没有服务器,并且必须没有任何办法来指定客户端如何处理响应。

BTW: The server does not "send" the response to the client, but the client requests the response from the server. 顺便说一句:服务器没有“发送”响应给客户端,但是客户端从服务器请求响应。 The client is acting, the server is reacting 客户端正在运行,服务器正在响应

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM