Surya Chandra
Surya Chandra

Reputation: 1591

Opening a file on click of a link on a jsp page

I have a link(say open file) on a JSP page. On clicking that link, I need to open a file. The location of the file is present in a table on the Database. Since "onclick" event is a Javascript event, I am clueless on how to obtain the file location. Pls help. Im relatively new to this stuff. Pls give an idea to implement this. I can proceed based on the idea

Upvotes: 1

Views: 2328

Answers (2)

MaVRoSCy
MaVRoSCy

Reputation: 17839

That's an easy question.

Basically you must have a form that post's to a jsp page or servlet.

There you should read a hidden element that will point to the file.

There you should write the file on the response and send it back to the user.

See my post How to offer download of local PDF file in Java? for more info

Upvotes: 0

Jigar Joshi
Jigar Joshi

Reputation: 240870

On click call the servlet which reads the fie location from DB and redirect the user to that file location

or read the file and write it out to response and set the headers

Upvotes: 1

Related Questions