Maxime
Maxime

Reputation: 560

How to add a link to a file in jsp?

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 ?

Upvotes: 3

Views: 1259

Answers (1)

Suresh Atta
Suresh Atta

Reputation: 121998

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

Upvotes: 5

Related Questions