aspose file tools*
The moose likes JSP and the fly likes Download the .lzh file with prompting file save dialog Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Download the .lzh file with prompting file save dialog" Watch "Download the .lzh file with prompting file save dialog" New topic
Author

Download the .lzh file with prompting file save dialog

vinoth khanna
Greenhorn

Joined: Jun 26, 2003
Posts: 13
Hi all,
I am trying to develop a jsp which is used to download a .lzh compressed file,and that gives me probs..
when i uncheck [Ask before opening this type of file - option] in the "file download" dialog prompt(open - save dialog box),
next time the file opens directly,and that is what i dont need,i need it to prompt it again.

I tried even to read and write it using servlet output stream,but unfortunately .lzh file cannot be read and written properly by streams like these.

Any ideas !

Thanx ,
Vinod


Thanx and Regards,<br />Vinod
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Set the content type to something that the browser won't recognize.

You may even want to add some random chars to the content type so subsequent hits will always be unrecongnized.

You'll also want to set the Content-Disposition header to give the downloaded file a name.

[ January 05, 2005: Message edited by: Ben Souther ]

Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
vinoth khanna
Greenhorn

Joined: Jun 26, 2003
Posts: 13
Thanx for ur idea! Even though I have file type recognized..
I had given file name like :

And still..
if i uncheck the option in open-save dialog ,i get opened directly by the default application..
so even though i randomly specify the mime type i get it opened directly..
It recognizes by file type it seems..

so how can i..

Regards,
Vinod
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

What happens if you change the file extension?
filename=SI_MANUAL_06.lzh.xxx
vinoth khanna
Greenhorn

Joined: Jun 26, 2003
Posts: 13
Ya I tried it ,it didn't work..if i change
sinece it just the file name to be displayed..it did not take it...

any more...
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Wait:
I tried even to read and write it using servlet output stream,but unfortunately .lzh file cannot be read and written properly by streams like these.


Just noticed that...

You mean your not streaming it?
How are you sending it to the client? If you're not streaming it, how can you be setting the content-type or content-disposition?
vinoth khanna
Greenhorn

Joined: Jun 26, 2003
Posts: 13
ya i ma streaming it...no doubt
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Can you post your code?
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Download the .lzh file with prompting file save dialog