Jetty has moved!
Jetty is a project at the Eclipse Foundation.
Homepage:http://www.eclipse.org/jetty
Downloads: http://download.eclipse.org/jetty/
Documentation:http://www.eclipse.org/jetty/documentation/current/
About:http://www.eclipse.org/jetty/about.php
Jetty Powered:http://www.eclipse.org/jetty/powered/
Contact the core Jetty developers at www.webtide.com
private support for your internal/customer projects ... custom extensions and distributions ... versioned snapshots for indefinite support ... scalability guidance for your apps and Ajax/Comet projects ... development services from 1 day to full product delivery
Skip to end of metadata
Go to start of metadata

Tutorial on FileUpload in Jetty6

In Jetty5, 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.

Simply modify the FileUpload servlet to your desired result. Simply bear in mind that the attribute name that you should get, should be the same as the file input item of the form.

  • No labels
Contact the core Jetty developers at www.webtide.com
private support for your internal/customer projects ... custom extensions and distributions ... versioned snapshots for indefinite support ... scalability guidance for your apps and Ajax/Comet projects ... development services from 1 day to full product delivery