The moose likes Struts and the fly likes File Uploader with a progress bar in Struts2 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "File Uploader with a progress bar in Struts2" Watch "File Uploader with a progress bar in Struts2" New topic

File Uploader with a progress bar in Struts2

fres nillo

Joined: Feb 01, 2011
Posts: 7
Hi all

I want to use an file uploader with a progress bar with Struts2, which works with all internet browsers but there is a problem with that.

I had to develop an Ajax solution with a boundary to "skip" the file upload interceptor (to send data like a form.submit() ), but the solutions works only if the browser permit read the file (in IE with an ActiveXObject which calls to system file read methods, with Firefox with FileReader, in Chrome 9 in other way; but Safari, Chromium and Opera don't have support with that because it's based in File HTML5 API).

I have test develop an Flex3 & 4 solution too, but the problem is that the server has an self-signed certificated ssl connection, and Flex doesn't support this certification type.

Is there an implementation/plugin (ot is it known) that supports ssl self-signed certification with Struts2 that works in all explorers? I see that in Struts1 works with a Listener that sends to client with JSON the status data uploaded, but I didn't see nothing in Struts2 that works fine.

abhishek rathur
Ranch Hand

Joined: Jan 14, 2010
Posts: 66
fres nillo

Joined: Feb 01, 2011
Posts: 7
Thanks for your quick response, but I don't have any idea how it's related with the question about a file uploader with progress status, please reply if I'm in a mistake.

I thought about using the interceptor execAndWait to send the progress like this (putting the progressBar in a iframe):
url: ...upload.action,
method: 'post',
handleAs: 'json',
load: function(response){
var progress = response.percentComplete;
document.getElementById('progressBar').style.width = progress+"%";

I extracted that from http://stackoverflow.com/questions/4073140/strut2-execandwait-interceptor-json-result-type-dojo-dijit-progressbar-ajax, but I don't have any idea what is or where is the FileProcessor class (non ProcessFileAction).

I agree. Here's the link: http://aspose.com/file-tools
subject: File Uploader with a progress bar in Struts2