Class ServletResourceDownloadHandler

All Implemented Interfaces:
DownloadHandler, ElementRequestHandler, Serializable

public class ServletResourceDownloadHandler extends AbstractDownloadHandler<ServletResourceDownloadHandler>
Download handler for serving a servlet resource for client download.

For instance for the file webapp/WEB-INF/servlet.json the path would be /WEB-INF/servlet.json

Since:
24.8
See Also:
  • Constructor Details

    • ServletResourceDownloadHandler

      public ServletResourceDownloadHandler(String path)
      Create download handler for servlet resource. Uses url postfix as file name from path.

      The downloaded file name and download URL postfix will be set to the file name from path. If you want to use a different file name, use ServletResourceDownloadHandler(String, String) instead.

      Parameters:
      path - path of servlet resource
    • ServletResourceDownloadHandler

      public ServletResourceDownloadHandler(String path, String fileNameOverride)
      Create download handler for servlet resource.

      The downloaded file fileNameOverride and download URL postfix will be set to fileNameOverride.

      Parameters:
      path - path of servlet resource
      fileNameOverride - download file name that overrides the name taken from path and also used as a download request URL postfix
  • Method Details

    • handleDownloadRequest

      public void handleDownloadRequest(DownloadEvent downloadEvent) throws IOException
      Description copied from interface: DownloadHandler
      Method that is called when the client wants to download from the url stored for this specific handler registration.
      Parameters:
      downloadEvent - download event containing the necessary data for writing the response
      Throws:
      IOException - if an IO error occurred during download
    • getUrlPostfix

      public String getUrlPostfix()
      Description copied from interface: ElementRequestHandler
      Optional URL postfix allows appending an application-controlled string, e.g. the logical name of the target file, to the end of the otherwise random-looking download URL. If defined, requests that would otherwise be routable are still rejected if the postfix is missing or invalid. Postfix changes the last segment in the resource url.
      Returns:
      String optional URL postfix, or null for "".