Interface MultipartRequestHandler

All Known Implementing Classes:
CommonsMultipartRequestHandler

public interface MultipartRequestHandler
MultipartRequestHandler provides an standard interface for struts to deal with file uploads from forms with enctypes of "multipart/form-data". Providers must provide a no-argument constructor for initialization.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    This is the ServletRequest attribute that should be set when a multipart request is being read and the maximum byte-length is exceeded.
    static final String
    This is the ServletRequest attribute that should be set when a multipart request is being read and the maximum file-count is exceeded.
    static final String
    This is the ServletRequest attribute that should be set when a multipart request is being read and the maximum byte-length or file-count is exceeded.
    static final String
    This is the ServletRequest attribute that should be set when a multipart request is being read and the maximum byte-length of a string parameter is exceeded.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    This method is called on when a successful form post has been made.
    This method returns all elements of a multipart request.
    This method is called on to retrieve all the FormFile input elements of the request.
    Get the ActionMapping instance for this request.
    Get the ActionServlet instance.
    This method is called on to retrieve all the text input elements of the request.
    void
    After constructed, this is the first method called on by ActionServlet.
    void
    This method is called on when there's some sort of problem and the form post needs to be rolled back.
    void
    Convenience method to set a reference to a working ActionMapping instance.
    void
    Convenience method to set a reference to a working ActionServlet instance.
  • Field Details

    • ATTRIBUTE_MAX_LENGTH_EXCEEDED

      static final String ATTRIBUTE_MAX_LENGTH_EXCEEDED
      This is the ServletRequest attribute that should be set when a multipart request is being read and the maximum byte-length or file-count is exceeded. The value is a Boolean. If the maximum byte-length or file- count isn't exceeded, this attribute shouldn't be put in the ServletRequest. It's the job of the implementation to put this attribute in the request if the maximum byte-length or file-count is exceeded; in the handleRequest(HttpServletRequest) method.
      See Also:
    • ATTRIBUTE_MAX_BYTE_LENGTH_EXCEEDED

      static final String ATTRIBUTE_MAX_BYTE_LENGTH_EXCEEDED
      This is the ServletRequest attribute that should be set when a multipart request is being read and the maximum byte-length is exceeded. The value is a Boolean. If the maximum length isn't exceeded, this attribute shouldn't be put in the ServletRequest. It's the job of the implementation to put this attribute in the request if the maximum byte- length is exceeded; in the handleRequest(HttpServletRequest) method.
      See Also:
    • ATTRIBUTE_MAX_STRING_LENGTH_EXCEEDED

      static final String ATTRIBUTE_MAX_STRING_LENGTH_EXCEEDED
      This is the ServletRequest attribute that should be set when a multipart request is being read and the maximum byte-length of a string parameter is exceeded. The value is a Boolean. If the maximum length isn't exceeded, this attribute shouldn't be put in the ServletRequest. It's the job of the implementation to put this attribute in the request if the maximum byte-length is exceeded; in the handleRequest(HttpServletRequest) method.
      See Also:
    • ATTRIBUTE_MAX_FILE_COUNT_EXCEEDED

      static final String ATTRIBUTE_MAX_FILE_COUNT_EXCEEDED
      This is the ServletRequest attribute that should be set when a multipart request is being read and the maximum file-count is exceeded. The value is a Boolean. If the maximum file-count isn't exceeded, this attribute shouldn't be put in the ServletRequest. It's the job of the implementation to put this attribute in the request if the maximum file- count is exceeded; in the handleRequest(HttpServletRequest) method.
      See Also:
  • Method Details

    • setServlet

      void setServlet(ActionServlet servlet)
      Convenience method to set a reference to a working ActionServlet instance.
    • setMapping

      void setMapping(ActionMapping mapping)
      Convenience method to set a reference to a working ActionMapping instance.
    • getServlet

      ActionServlet getServlet()
      Get the ActionServlet instance.
    • getMapping

      ActionMapping getMapping()
      Get the ActionMapping instance for this request.
    • handleRequest

      void handleRequest(HttpServletRequest request) throws ServletException
      After constructed, this is the first method called on by ActionServlet. Use this method for all your data-parsing of the ServletInputStream in the request.
      Throws:
      ServletException - thrown if something goes wrong
    • getTextElements

      HashMap<String,String[]> getTextElements()
      This method is called on to retrieve all the text input elements of the request.
      Returns:
      A HashMap where the keys and values are the names and values of the request input parameters
    • getFileElements

      HashMap<String,FormFile[]> getFileElements()
      This method is called on to retrieve all the FormFile input elements of the request.
      Returns:
      A HashMap where the keys are the input names of the files and the values are FormFile objects.
      See Also:
    • getAllElements

      HashMap<String,Object> getAllElements()
      This method returns all elements of a multipart request.
      Returns:
      A HashMap where the keys are input names and values are either String arrays or FormFiles.
    • rollback

      void rollback()
      This method is called on when there's some sort of problem and the form post needs to be rolled back. Providers should remove any FormFiles used to hold information by setting them to null and also physically delete them if the implementation calls for writing directly to disk.

      NOTE: Currently implemented but not automatically supported, ActionForm implementors must call rollback() manually for rolling back file uploads.

    • finish

      void finish()
      This method is called on when a successful form post has been made. Some implementations will use this to destroy temporary files or write to a database or something of that nature.