Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

JSP and Download File

Status
Not open for further replies.

jem122974

Programmer
Nov 1, 2001
114
0
0
US

Here is what I would like to do:

1) Store the UNC path to a file in my database.
2) Display on my JSP the name of the file as a link.
3) Give the user the dialog to ask if they want to save or open the file when they click the link.

I can do 1 and 2, but how do I do 3? Can anyone point me in the right direction?

Thanks,
Jon Mitchell [worm]
 
Save or open is a function of the browser. If the file type is one that the browser is set up to load automatically, then it will. Otherwise, it will ask if the user wants to open or save it. I don't think you can control that via jsp.

So if you always want the dialog to be displayed, you would have to make the extension on the file something no browser would recognize (like .xyz or something).
 
You can use a checkbox or radio button to select either of the two and route the information to another JSP which would either save or open the file depending on the value of the checkbox or radio button.
 
Just changing the filename won't always work. You also need to be sure to set the MIME type to something that won't be loaded.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top