|
Fish & Chips Club 4.10.0.0 | ||||||||
PREV PACKAGE NEXT PACKAGE | FRAMES NO FRAMES |
See:
Description
Class Summary | |
---|---|
FileUploadFilter | Wrap the underlying request using
FileUploadWrapper ,
such that a file upload can be handled in the same way as a regular form. |
FileUploadWrapper | Wrapper for a file upload request. |
Image | Model Object for an Image. |
ImageDeleteAction | Delete a single image, and refresh the image listing. |
ImageDownloadAction | Fetch an image from the database, and serve it directly to the client, without using a JSP. |
ImageUploadAction | Overwrite the image used on the home page. |
Upload image files to the server. Saves images both to the file system, and to the database.
This feature exercises WEB4J support for file upload forms. WEB4J itself has no API related specifically to file uploads. The web4j data layer works with an InputStream. In Servlet 3.0, the servlet API itself will give you access to the uploaded file, as an InputStream. In Servlet 2.5, you can do the same, but third-party tools are necessary.
This package uses Servlet 2.5, along with the Apache Commons File Upload tool. The generous Apache License will likely allow you to use it in your applications as well.
It's interesting to note that even if a single file upload control is present in a form, then all of the form's data, including that passed by controls that are not file upload controls, are not available in the usual way through the Servlet 2.5 API.
For file upload forms, the usual HttpServletRequest.getParameter(String) method does not work - for all parameters in the request, not just those related to file upload controls. It will return only null values.
As a consequence, the following will not work as well (but see below):
However, it's easy to render these items functional for file upload forms by using a wrapped request and a simple filter. That technique is used here.
See this Java World article for further information.
It's important to note that most browsers (all?) do not respect the value attribute for file upload controls. As a result, this makes it impossible for web4j (or any similar tool) to pre-populate such controls dynamically. In the case of an 'update' operation, the web4j mechanism for pre-populating the data in a file upload control doesn't work. So, any update operations for binary data needs to be handled separately. (One option is to use only add and delete operations, with no update at all.)
|
Fish & Chips Club 4.10.0.0 | ||||||||
PREV PACKAGE NEXT PACKAGE | FRAMES NO FRAMES |