Temp files download servlet v. 1.3

This component lets you support the downloading for temporary files. Suppose your application creates some file that will be available for the downloading during the restricted time and should be automatically deleted after the downloading. For example almost all of the services for the music/pictures/games downloading on the mobile phones work so. That is what this servlet is for. How to use it:

1) download tempdownloadPackage.jar and save it in WEB-INF/lib

2) describe TempDownload servlet in your web.xml file


3) define a mapping:


and now you can use it:


servlet will download this file from the server. By default servlet will search file in the root (docBase) directory of your servlet container. You may set an initial parameter described another directory on your server. Parameter name is dir. For example:


and this directory (file store) could be located even the outside of your web application.

Also you can provide the following parameters for this servlet:

ttl - describes a time (in seconds) when any file will be available for the downloading after the creation. Default value is 86400 (24 hours).
error - lets you describe some URL users requests will be redirected to in case of missed files. If this parameter starts with http:// than servlet redirects the request. Otherwise servlet assumes the local resource and request will be forwarded. By default is empty (no redirection).
multiple - enable/disable multi-times downloading. Possible values are true or false. Default value is false (file will be deleted after the first download).
gzip - enable/disable data compression during the downloading. Possible values are true or false. Default value is false.

Note: servlet may clean the directory during the startup!

For downloading:

servlet: tempdownloadPackage.jar  

 © Coldbeans    Comments?

See also JSOS - the largest collection of servlets and filters.

Also in Coldtags: