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
Asked
Active
Viewed 2,284 times
1
-
where is the file stored? do you have it also stored in the db? – MaVRoSCy Jul 19 '12 at 06:36
-
currently on my local only, but will have to hoist this JSP on a remote server later. The file will reside on the server only at that time – Surya Chandra Jul 19 '12 at 06:37
-
Are you using any framework for this thing like struts?? – Prateek Jul 19 '12 at 06:48
-
No, im not using any framework – Surya Chandra Jul 19 '12 at 06:51
2 Answers
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