Win a copy of Head First Agile this week in the Agile forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

ServletFileUpload ProgressListener  RSS feed

 
sam wootton
Ranch Hand
Posts: 105
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Many thanks in advance for any help or advice, i'm stuck, so much appreciated.

I have a Servlet that accepts a file upload from a standalone Swing client:

Client uses:



Servlet uses:




This is working fine.

I have a progress listener:



This also works fine, and reports the correct % done.

My question:

How do i print the % done to the client?

I was thinking that i could pass the PrintWriter in to the ProgressListener?:



But i guess i need to open up a Stream? I need to be able to report back to my Java standalone client, 94%,95%,96%... etc.

Regards, Sam
 
sam wootton
Ranch Hand
Posts: 105
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
These seem to both suggest the same (rather messy) workaround:

http://toolongdidntread.com/android/android-multipart-post-with-progress-bar/

http://stackoverflow.com/questions/254719/file-upload-with-java-with-progress-bar

of creating a custom MultiPartEntity and overriding read and write methods.

Surely there is a different way?

Regards, Sam
 
sam wootton
Ranch Hand
Posts: 105
2
 
sam wootton
Ranch Hand
Posts: 105
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I managed it by creating own version of suggestions above.

I think mine is simplier, but dont know about performance.

Create a custom MultipartEntity:



In the class that calls/executes this:



And implement import org.apache.commons.fileupload.ProgressListener (could create interface.. but this seemed convenient and kept it in the commons upload pkg):



Regards, Sam
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!