SecureDownload servlet v. 1.4

A simple component you may use for the secure files downloading. Servlet lets you hide from the visitors the location for the downloaded file. The usage is:
 


http://your_host/servlet/SecureDownload?some_key

Servlet will find this some_key in the text (properties file) and get the real location (as well as a name) for the downloaded file. And your configuration file will be provided as an initial parameter for this servlet. Of course, You can update content of this file at any time. Parameter name is base. Also you can define an initial parameter
expires. It describes a caching time (in seconds) for the downloaded resource.

a) copy secureDownloadPackage.jar into WEB-INF/lib directory

b) describe this servlet in your web.xml file:
 

    <servlet>
     <servlet-name>SecureDownload</servlet-name>
     <servlet-class>com.jsos.secure.SecureDownloadServlet</servlet-class>
     <init-param>
      <param-name>base</param-name>
      <param-value>full_path_to_your_properties_file</param-value>
     </init-param>
    </servlet>

c) describe a mapping for this servlet in your web.xml file:
 


     <servlet-mapping>
     <servlet-name>SecureDownload</servlet-name>
     <url-pattern>/servlet/SecureDownload</url-pattern>
     </servlet-mapping>

Properties file is a text file, each line describes one file in the form of
  your_key=real_path_to_your_file

Empty lines and any line starts with # or // are ignored. You can use file path as well as URI here. For example:
 


  key1=c:\myfiles\document.doc
  key2=http://myhost/mydir/picture.mp3

In this case for example http://your_host/servlet/SecureDownload?key2 will actually download the file from http://myhost/mydir/picture.mp3

Note: the evaluation version supports up to 5 keys in the properties file.

For downloading:

servlet: secureDownloadPackage.jar  
 
 © Coldbeans    Comments?
 
See also JSOS - the largest collection of servlets and filters.

Also in Coldtags: