First Off, awesome tutorial, Jinu! Thanks a bunch! It put me on right path. I did have to make tiny change in the java file in order to address issues mentioned below by Reshu and Dinesh. When I downloaded code as-is from your link, I did face exact same issue Reshu faced. As for Dinesh's issue, I did notice that in your example as well, output file doesn't pick up the new name typed in input box. e.g. you typed flower, but it still created tulip.jpg. I had to replace this part of java program if (fileItem.getSize() > 0) { fileItem.write(new File("D:\\uploaded_files\\" + fileItem.getName())); } with following code: if (fileItem.getSize() > 0) { String outputFileNm = ((file_name==null || file_name.equals(""))?fileItem.getName():file_name); String fileNameSuffix = "." + FilenameUtils.getExtension(fileItem.getName()); File outputFile = new File(outputFileNm); fileItem.write(new File("C:\\LearningIsFun\\uploaded_files\\" + outputFile.getName()+fileNameSuffix)); } when you use above code, you will need to import FilenameUtils apache commons package. Disclaimer: All, I am not an expert. I just pasted what seems to be working for me. If there is better way to handle it, please do post it here. It will be useful to me and everyone else.
hey can u help me with... how i can submit data of form with enctype="multipart/form-data" if i use request.getParametr it displays null .. what method should i use to submit string values pls help
Explanation is nice but, you skipped the step of adding the jar file into web-inf/ lib and also creating the upload handler .java file.... can you please explain that steps
D:\UploadFilesC:\Users\Public\Pictures\Sample Pictures\Tulips.jpg... its taking Full path after copy pasting the same code as shared in above link.. Please let me know how to resolve it.