Hello Peter, I am glad to hear you have solved this problem! Although I don't know turbine and velocity well enough to comment on your implementation, I think I get the general idea. It doesn't seem too different from what Andrei Cioroianu wrote about at http://www.onjava.com/pub/a/onjava/2003/06/11/jsp_progressbars.html, albeit his has more to do with the progress of a long-running task rather than a long upload.
One question. You wrote, "On form submission, the ParameterParser(request parser) reads the unique id for the ProgressReporter obtained at 1. It [the ParameterParser] uses this to obtain the referenced object from the cache and passes this to the upload service which updates it as the request is read." I don't understand how the upload service can update the referenced cache object as a request is begin read. Isn't the reading of a request an atomic operation? IOW, doesn't the API read the request in its entirety before giving it to the upload service? I'm feeling my lack of turbine and velocity knowledge is hurting me here... Thanks, Eric H. Jung Russell/Mellon Analytical Services 1-617-382-1373 Everett, MA, USA -----Original Message----- From: Peter Courcoux [mailto:[EMAIL PROTECTED] Sent: Tuesday, December 23, 2003 4:11 PM To: Jakarta Commons Developers List Subject: Re: [Fileupload] Progress bar Hi Eric, My implementation using turbine is a bit more complex than this but this should give you the idea :- 1. Populate the VelocityContext of the page containing the fileupload form with a uniqueid to a cached reference to a new instance of a ProgressReporter object. This is done in the page setup using a turbine pulltool. 2. I use a time expired cache so that if something goes wrong the cache cleans up after itself. 3. Add the unique id to the upload form using a known parameter name. 4. Add a javascript onClick handler to the form to open a new upload status window. Pass the unique id to the window. 5. On form submission, the ParameterParser(request parser) reads the unique id for the ProgressReporter obtained at 1. It uses this to obtain the referenced object from the cache and passes this to the upload service which updates it as the request is read. 6. The upload status window uses the same uniqueid it was given at point 4 and again using a pull tool queries the server for the ProgressReporter object and displays the result. The UploadStatus window is set to reload every 5 seconds and consequently displays the updated status. When the ProgressReporter object is released when the request is completely read, the window is set to close, again using javascript. This has been working for 7 or 8 months now very successfully. The server on which this is used regularly receives uploads from a few Kb to an average of 20MB and occasionally up to its limit of 100MB. Rather than implement a progress bar, I report the size of the request, the bytes read and the name of the file object currently being processed. It would, of course be relatively easy to take this information and produce a progress bar. Does this make sense? I intend to post a detailed set of examples and instructions on the turbine site (In fact I produced a draft in May or June but I'll have to review it all again), but only when I have the support in commons-fileupload. It's no good to anyone until then! Regards, Peter On Tue, 2003-12-23 at 20:29, Eric H. Jung wrote: > Sorry for not replying to the thread started by Eric Pugh at > http://www.mail-archive.com/commons-dev%40jakarta.apache.org/msg32368.html, > but I've only just joined commons-dev as suggested to me by Yoav on > tomcat-dev. > We were discussing a related topic there. > > I've gone through signifcant efforts to extend commons-fileupload using > Listener interfaces > in order to support a progress bar to no avail. I researched what others > have done, > including but not limited to > http://www.javazoom.net/jzservlets/uploadbean/uploadbean.html > (which, by the way, seems to redistribute commons-fileupload without any > mention of Apache). > > I do not see how this problem can be tackled without writing one's own (or > extending another) > servlet container. There is currently no way in the servlet spec to know the > number of bytes > that have been read as a ServletRequest is being processed. By the time > Servlet.service() or > Filter.doFilter() are called, the *entire* InputStream has been read from > the socket, leaving no > way to provide user feedback during the upload. > > I could be totally off base here, and if I am, I'd appreciate it if someone > would show me the light. > > Thank you, > Eric H. Jung > [EMAIL PROTECTED] > > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] -- Peter Courcoux <[EMAIL PROTECTED]> --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]