This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Struts and the fly likes multipart/form-data cancel issue Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "multipart/form-data cancel issue" Watch "multipart/form-data cancel issue" New topic
Author

multipart/form-data cancel issue

Milan Tomc
Greenhorn

Joined: Mar 06, 2006
Posts: 17
Hi all,

I'm uploading files to a database.

When the user chooses the file and presses "upload-button" (submit) the data starts streaming. Then I wanted to see what would happen if I click something else whilst busy (like another link, button or browsers stop button) and that has cost me a day and a half now.

What i get is:

00:17:43,578 ERROR [CommonsMultipartRequestHandler] Failed to parse multipart request
org.apache.commons.fileupload.FileUploadException: Processing of multipart/form-data request failed. Stream ended unexpectedly
at org.apache.commons.fileupload.FileUploadBase.parseRequest(FileUploadBase.java:384)
at org.apache.commons.fileupload.FileUploadBase.parseRequest(FileUploadBase.java:268)
at org.apache.struts.upload.CommonsMultipartRequestHandler.handleRequest(CommonsMultipartRequestHandler.java:185)
at org.apache.struts.util.RequestUtils.populate(RequestUtils.java:405)
at org.apache.struts.action.RequestProcessor.processPopulate(RequestProcessor.java:818)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:194)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:462)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

-------------------------------------------------------------------
User sees no problems. The application does what user "clicks".

What really bothers me is the fact that, once user clicks on "upload", every byte must be transmited. If I click on browsers stop button, I get the above exception. After that I click on something else and see on the status bar that the browser is sending the rest of the bytes (I tested with 50 Mb). When this is done the application does what it is told to.

So, did somebody think of a way to let the user change his mind, cancel the upload, and without waiting for tens of (canceled) Megabytes to be transmited, continue as he pleases?
Milan Tomc
Greenhorn

Joined: Mar 06, 2006
Posts: 17
Or with other words:

Is there a way to catch this exception and let the browser know we are no more interested in de request/stream?
 
Consider Paul's rocket mass heater.
 
subject: multipart/form-data cancel issue