This component lets you provide such a service as one time downloading. Suppose your application creates some file that will be available for the downloading only once 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 oncedownloadPackage.jar and save it in WEB-INF/lib 2) describe OnceDownload servlet in your web.xml file
<servlet> <servlet-name>OnceDownload</servlet-name> <servlet-class>com.jsos.oncedownload.OnceDownloadServlet</servlet-class> </servlet> 3) define a mapping:
<servlet-mapping> <servlet-name>OnceDownload</servlet-name> <url-pattern>/servlet/OnceDownload</url-pattern> </servlet-mapping> and now you can use it:
http://your_host/servlet/OnceDownload?file_name 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:
<servlet> <servlet-name>OnceDownload</servlet-name> <servlet-class>com.jsos.oncedownload.OnceDownloadServlet</servlet-class> <init-param> <param-name>dir</param-name> <param-value>full_path_to_your_directory</param-value> </init-param> </servlet> 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: 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).
For downloading: servlet: oncedownloadPackage.jar
See also JSOS - the largest collection of servlets and filters.
|
Also in Coldtags:
|