How to add a link to a file in jsp?

java, jsp, tomcat

Solution

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

Problem

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 ?

Original source

Related problems