1

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

Surya Chandra
  • 1,561
  • 5
  • 27
  • 42

2 Answers2

1

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

jmj
  • 237,923
  • 42
  • 401
  • 438
0

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

Community
  • 1
  • 1
MaVRoSCy
  • 17,747
  • 15
  • 82
  • 125