You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Rhino <rh...@sympatico.ca> on 2003/07/29 16:59:19 UTC

[FileUpload] Handling File Size Error

Can anyone tells me how to modify my file upload servlets to ensure that the contents of an <input type="file"> control are still present when I return to the form?

I have two servlets: FileUploadFormServlet displays the form and FileUploadHandlerServlet edits the input, displays error messages if there are any errors and stores the input if there are no errors.

These two servlets are now working pretty well now except for one thing. I am doing edits on each of the files which are to be uploaded, including a check to see if the file is larger than an individual size threshold I have set. (This is something I've created myself because I want an individual size limit, not the aggregate limit provided by the Commons FileUpload team.) When an individual file size is too large, I create a message and display it, then invite my user to press the back button on their browser to go back to the form to modify the form - either replace the name of the overly large file with a smaller file or blank it out altogether.

Everything works fine except that when the user gets back to the form, all of the fields that are <input type=file> are blank. The <input type=text> fields retain their original values. I would like the <input type=file> controls to also contain their original value. What do I need to do to make that happen?

I've never seen this "blanking" behaviour in other forms but this is the first time I've written a servlet containing an <input type=file> control....

I am running Tomcat 4.1.24. My browser is IE 6.0.2800.xpsp2.030422-1633. My OS is Windows XP Pro with all critical service applied.

Rhino
---
rhino1 AT sympatico DOT ca
"If you want the best seat in the house, you'll have to move the cat."