By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,636 Members | 1,213 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,636 IT Pros & Developers. It's quick & easy.

Is this possible?

P: n/a
Firstly sorry for cross posting but not really sure which group this belongs
in?

Anyway, I have a webapp that basically consists of 2 screens, search critera
& results

I want to be able to provide a way for the user to download a zipped up
excel file of the results.

I can quite easily create a excel file using POI & zip it up using
java.util.zip which creates a zip file on the server. Then add a link to
this file on the results page which when clicked will produce the standard
download dialog box & alls well.

The problem is I have to create the zip file every time the results
generated & displayed but some users might not want this faclity!

Is it possible to have a button/link etc... that when clicked create's the
zip file & produces the download dialog box WITHOUT changing the results
page?

Any ideas?

thanks

harry
Jul 20 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a


Harry wrote:
Firstly sorry for cross posting but not really sure which group this belongs
in?

Anyway, I have a webapp that basically consists of 2 screens, search critera
& results

I want to be able to provide a way for the user to download a zipped up
excel file of the results.

I can quite easily create a excel file using POI & zip it up using
java.util.zip which creates a zip file on the server. Then add a link to
this file on the results page which when clicked will produce the standard
download dialog box & alls well.

The problem is I have to create the zip file every time the results
generated & displayed but some users might not want this faclity!

Is it possible to have a button/link etc... that when clicked create's the
zip file & produces the download dialog box WITHOUT changing the results
page?

Any ideas?


Assuming you are working with Servlets or JSP on the server you need to
find out how to set a HTTP response header with them and set a headers alike
Content-Type: application/octet-stream
Content-disposition: attachement; filename=whatever.zip
and then stream the zip to the browser
--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 20 '05 #2

P: n/a
yes

simply have the download URL pointing to a servlet (or whatever server side
technology you are using)

in the servlet build the zip file, set the content-type to
application/x-zip-compressed and write out the zip data as the HTTP body.

note that you with java.util.zip, you can simply open up a zipOutputStream
on the response's output stream so you don't need to save it to a file at
all.

I would also suggest the url ends in .zip as well. Sometimes IE seems to
look at the file extension of the URL as well as the content type

Andy

"Harry" <a@abc.com> wrote in message
news:WW*********************@news-text.cableinet.net...
Firstly sorry for cross posting but not really sure which group this belongs in?

Anyway, I have a webapp that basically consists of 2 screens, search critera & results

I want to be able to provide a way for the user to download a zipped up
excel file of the results.

I can quite easily create a excel file using POI & zip it up using
java.util.zip which creates a zip file on the server. Then add a link to
this file on the results page which when clicked will produce the standard
download dialog box & alls well.

The problem is I have to create the zip file every time the results
generated & displayed but some users might not want this faclity!

Is it possible to have a button/link etc... that when clicked create's the
zip file & produces the download dialog box WITHOUT changing the results
page?

Any ideas?

thanks

harry

Jul 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.