This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
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?
Joined: Mar 06, 2006
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?