3

I have a JSP page, and I would like to display a link that allows the user to download a file. That file is present on tomcat server, let's say in that directory :

C:\myDirectory\myFile

How can I download this file through a JSP ?

Suresh Atta
  • 118,038
  • 37
  • 189
  • 297
Maxime
  • 570
  • 3
  • 15

1 Answers1

5

When you gave a link a in jsp like

C:\myDirectory\myFile

It tries to open the file on clients machine. Not the server machine.

Make a request to server. And write the stream to response.

A good start will be :Implementing a simple file download servlet And check the answer

Community
  • 1
  • 1
Suresh Atta
  • 118,038
  • 37
  • 189
  • 297