Tutorial on FileUpload in jetty6
In jetty 5, MultiPartRequest was used for file uploading. In jetty6, MultiPartRequest was changed to MultiPartFilter.
MultiPartFilter decodes the multipart/form-data stream sent by a HTML form that uses a file input item. A File object is then created and stored to the request as an attribute. The attribute name is equal to the name of the file input item of the form being submitted. Therefore if you have a file input item with a name of "userfile1", the attribute name for the File object is "userfile1".
Here is a quick tutorial for uploading files.
First, create the page with a form of enctype equal to multipart/form-data. File uploading won't work if you have a different enctype. Inside the form element, add an input file item.
Create a web.xml with filter and servlet mapping for /fileupload url because that's the action we specified in our form.
Create a FileUpload servlet.
The FileUpload servlet above simply stores the File being uploaded to the project target directory.
Below is a utility class that is responsible for copying a file.
Simply modify the FileUpload servlet to your desired result. Simply bare in mind that the attribute name that you should get, should be the same as the file input item of the form.