Provides a secure method for downloads of any file, including files that can not be
accessed via a normal web request.
DownloadHandler expects a jWebApp request parameter named 'filename' that contains the name
of a file that will be returned to the client via the files expected content type. If the
jWebApp request parameter is not defined then a normal request parameter should be defined.
DownloadHandler also looks for a jWebApp request parameter named 'directory'. If directory
is defined then the file defined in the request parameter can only be retreived from the
download directory. The filename defined in the request parameter should be relative to the
directory. This should always be defined! If it is not defined, then the file parameter
should not be accessable to the user, who could potentially download anything.
DownloadHandler can access files anywhere and uses ServletContext.getResource() to
locate the file, so the file name can be relative to the web context. DownloadHandler allows
you to protect downloads via security roles, and gives you the ability to narrow the download to a
specific directory and/or file. Therefore, DownloadHandler provides a highly secure method for
file downloads.
|