0

I am trying to download a file from the server to the client machine using 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? Or is it possible in servlets to transfer a file from the server to a location specified by the client?

kais
  • 63
  • 1
  • 13
  • possible duplicate of [How to download a file from the server using Servlet](http://stackoverflow.com/questions/10683215/how-to-download-a-file-from-the-server-using-servlet) – Stefan Jul 22 '14 at 09:42
  • @Stefan I don't think that's a duplicate. The question is about who is in control: the server or the client. –  Jul 22 '14 at 09:43

1 Answers1

0

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

  • Hi, I ll make clear the complete scenario what needs to be working. Suppose my server is deployed on machine A and client is deployed on machine B. I want the client to access the server from machine B. I also want the client to search for a specific file on machine A. The client also gives the path on the local machine(B) where the file found on server (A) needs to be saved. Finally the server should send that file to the location mentioned by the client on machine B. Is there any code supporting this problem? – kais Jul 22 '14 at 14:14
  • In your question you mention servlets. Is that a requirement? What technologies do you *have* to use? –  Jul 22 '14 at 14:33
  • Basically,it has to be done using tomcat server.Using servlets is not a requirement.But I have to use tomcat server for sending file.If theres an example suiting my requirement then please do post it here – kais Jul 23 '14 at 03:20