Force Download Servlet v. 1.1

Here is a useful component for delivering multimedia file downloads to your users. Typically, browsers will attempt to play or stream such files when direct links are clicked. With this servlet, provide a link to a multimedia file and a dialogue box will provide users the choice of saving the file or opening it. Technically this servlet will set content type to the downloaded media files to application/octet-stream regardless of the mime type provided by the server. How to use it:

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

2) describe ForceDownload servlet in web.xml file  


    <servlet>
     <servlet-name>ForceDownloadServlet</servlet-name>
     <servlet-class>com.jsos.download.ForceDownloadServlet</servlet-class>
    </servlet>

3) define a mapping. E.g.:
 


    <servlet-mapping>
     <servlet-name>ForceDownloadServlet</servlet-name>
     <url-pattern>*.mp3</url-pattern>
    </servlet-mapping>

and now for any mp3 file requested from your site:
 


http://your_host/data/some_file.mp3

this servlet will set mime type to application/octet-stream (force file downloading rather than playing).

For JSP see also Download taglib in Coldtags suite

For downloading:

servlet: forcedownloadPackage.jar  
 

 © Coldbeans    Comments?
 

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

Also in Coldtags: