2

I was working on a file upload task using jsp and servlet. I read many questions and answers regarding this topic on stackoverflow. I came accross this question on stckoverflow

How to upload files to server using JSP/Servlet?

Where Balusc has gave an nice and descriptive answer to the question. He has also give the reference to his blog regarding multipart filter which is a complete informative tutorial with a complete working example code. link is here http://balusc.blogspot.in/2007/11/multipartfilter.html Thanks to Stackoverflow and Balusc Sir for there nice explaination of the solution regarding this task.

I have implemented the same code of multipart filter and other code in the given example with small chages as per my requirement for my file upload application. My application is working absolutly fine.

Now the enhancement part comes in to picture. I want to add a file upload progress bar with this application which shows file upload progress. I googled regarding this on web I found many answers but all are mess. Can any one explain properly how to add progress bar with above example given in above blog. Where do I need to do the changes in the code given in above blog to show the file upload progress bar.

I am using Apache Tomcat server 6.0 Apache file upload library commons-fileupload-1.2.2.jar and commons-io-2.4.jar Java 1.6 on Windows and OpenJDk 7 on linux

Please guide me friends in this problem.

Thanks You!

Community
  • 1
  • 1
Param-Ganak
  • 5,787
  • 17
  • 50
  • 62
  • @BalusC Sir! I have read your blog regarding Mulitpart filter and found it very usefull for me. I have implemented your example given in the blog. Now I want to Add file upload Progress bar in to it. So What changes do I have to make in the code. – Param-Ganak Mar 12 '13 at 08:13
  • Hi, have you managed to solve this? I'm having the same problem. – MinionAttack Jul 12 '22 at 11:29

1 Answers1

2

I just tried the progress bar for single file upload with exactly the same version of libraries your are using, please refer to fileupload_progressbar.jsp and UploadProgressServlet.java.

Add a progress listener to servlet, keep the progress value somewhere, then you can get progress value via ajax and update the status of progress bar at client side as needed.

Hope this helps.

benbai123
  • 1,423
  • 1
  • 11
  • 11
  • Is it possible to achieve the same without using apache.commons jar files? – Surya Teja Karra Apr 28 '17 at 11:10
  • @SuryaTejaKarra, sure, if you are using servlets 3.0 or later, you can replace those part of the code which handles uploading with `@MultipartConfig` and `getParts()` as discribed here: https://docs.oracle.com/javaee/6/tutorial/doc/glraq.html – I.R. Feb 16 '21 at 09:46