ZIP download from webapp

Hi all.

In my web app I let the user download ZIP files.

These files are archived in a DB as "blobs", so they are generated each time an user make a proper request.

Everything is working fine, but I don't know how to make the application "decide" the name of the ZIP, that is the name seen by the user at download time.

In fact, the ZIP is always named with the name of the servlet which manages the user request, while I'd like the ZIP was named with a proper name, stored in the DB.

I've tried working by filter, calling a "fake" URL in order to make it intercepted by the filter, but the problem is that the URL doesn't exist, as the files are not stored anywhere but in the DB, so the filter is never called.

Any other idea?

Thanks in advance for any help!

[813 byte] By [robicha] at [2007-10-2 10:22:27]
# 1

Assuming you are outputting the zip data to the browser using a servlet or something, you can set the output filename by providing a response header:

response.setHeader("Content-Disposition","attachment; filename=\"YOURFILENAME\"");

That should do it.

gimbal2a at 2007-7-13 1:54:31 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2
Thanks a lot!That's what I was looking for!!
robicha at 2007-7-13 1:54:31 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...