aspose file tools*
The moose likes Servlets and the fly likes Displaying the File Download dialog box Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Displaying the File Download dialog box" Watch "Displaying the File Download dialog box" New topic
Author

Displaying the File Download dialog box

Siphiwe Madi
Ranch Hand

Joined: Aug 16, 2007
Posts: 70
Hi,

I'm trying to allow users of the site to be able to download a file (e.g Calendar Image file) when they click the Download link.

I have the url and have put it inside the tag
<a href="<%=URL%>">Download</a>, but this is opening the image in the window.

I want it to open the File Download dialog box with the options to Save or Open the File.

I'm doing this in a jsp within a portlet.
Your help will be greatly appreciated.

Kind Regards,
Siphiwe Madi
[ July 23, 2008: Message edited by: Bear Bibeault ]

Regards, Siphiwe Madi
[SCJP, SCWCD, __] Next ... scjwsd
Amit Ghorpade
Bartender

Joined: Jun 06, 2007
Posts: 2716
    
    6

I don't know how to display that dialog box
But I think this is because the browser knows of the image file. If you put something else in the href like say a .xyz file then the browser will show the dialog you are talking of.

Same thing applies to PDF documents when you have a reader in place, the browser opens the file opens it or displays the dialog you are talking of.


Hope this helps


SCJP, SCWCD.
|Asking Good Questions|
mohan kumar r
Ranch Hand

Joined: Jan 19, 2006
Posts: 38
Hi,
portal framework you are using may stop/override download popup window. If i am not wrong every window is a part of framework once you integrate your application with framework.I have faced the same problem once and i have a provision to specify not to dispaly pop up window in portal framework as below and that's solves the problem.
<a href="url?...&pCpslayout=false">payload</a>


mohan
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

You can't force browsers to do anything but, the best way to convice one to prompt the user with a Save/Open dialog box is to set the content type to something that the browser wouldn't have an association for.

When you do this, if you also set the Content-Disposition header, you can suggest that the browser use a particular file name when saving and (if the contentType is known, suggest that the browser not try to open the associated application inline but instead prompt the user with the save/open dialog box.

In our JSP FAQ under JspAndExcel there is an example that sets both the Content-Type and the Content-Disposition headers.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Displaying the File Download dialog box