470,636 Members | 1,553 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,636 developers. It's quick & easy.

Is this possible?

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
2 3875


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
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.

Similar topics

4 posts views Thread by Julia Briggs | last post: by
36 posts views Thread by rbt | last post: by
1 post views Thread by AAA | last post: by
25 posts views Thread by Piotr Nowak | last post: by
14 posts views Thread by bjorklund.emil | last post: by
1 post views Thread by Korara | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.