// Get our multipart form final ResourceBundle rb = getResources(); final FormData form = (FormData)req.parseContent(); if (form == null || !form.getIsMultiPart()) { throw new ResourceBundleWebScriptException(Status.STATUS_BAD_REQUEST, rb, ERROR_BAD_FORM); } // Find the File Upload file, and process the contents boolean processed = false; for (FormData.FormField field : form.getFields()) { if (field.getIsFile()) { // Logic to process/save the file data here processUpload( field.getInputStream(), field.getFilename()); processed = true; break; } } // Object if we didn't get a file if (!processed) { throw new ResourceBundleWebScriptException(Status.STATUS_BAD_REQUEST, rb, ERROR_NO_FILE); }