Servlet Design Question

R

Rhino

I'm looking for some design suggestions for a problem I'm having with a File
Upload servlet, specifically the error handling for a particular situation.

I'm using the Jakarta Commons FileUpload jar (Version 1.0) in a servlet that
provides a form and allows the user to upload up to three files to the
server. I have written code that inspects each of the files that the user
wants to upload to ensure that it is not larger than a specific size and
this code works fine. However, I am having trouble figuring out the right
way to handle the error when it occurs.

Currently, I am making two passes through the List of items obtained from
the form. The first pass simply ensures that each file that is to be
uploaded is below a certain size. The second pass stores the form inputs and
any files that are to be uploaded. After the first pass, if any errors have
been detected, I generate a page identifying the files that are too large
and display it for the user.

I would like the user to be able to spend as long as he/she needs on the
page, then press a button to return to the form so that they can adjust it
(by choosing a smaller file to upload or by blanking out the file name) and
try submitting their input again. At the moment, I tell them to use their
Back button to return to the form when they are ready.

Unfortunately, the <input type=file> fields are blank when they return. I'm
not sure why that happens but this really messes me up because I want the
form to have the exact same data on it that it had when the user pressed
Submit. All of the data in the other fields is intact EXCEPT for the <input
type=file> fields which are always blank.

Therefore, I have two questions:
1. Is there any way to change the behaviour of the form servlet and the
servlet that edits the form's input so that pressing the Back button will
return the user to a form that has all of the values still on the form
INCLUDING the file names that they put in the <input type=file> fields?
2. If not, is there some other way to design my servlet so that I can
display an error message to the user for as long as he/she needs in order to
read it, then give them some way of signalling that they are done, then
display the original input form with all of the form fields, including the
<input type=file> fields, intact?

I can't be the first person to ever encounter this situation so I'd
appreciate any guidance you could offer on how to handle this problem.
 
V

VisionSet

Rhino said:
[....]
Therefore, I have two questions:
1. Is there any way to change the behaviour of the form servlet and the
servlet that edits the form's input so that pressing the Back button will
return the user to a form that has all of the values still on the form
INCLUDING the file names that they put in the <input type=file> fields?
2. If not, is there some other way to design my servlet so that I can
display an error message to the user for as long as he/she needs in order to
read it, then give them some way of signalling that they are done, then
display the original input form with all of the form fields, including the
<input type=file> fields, intact?

Sounds like Struts might be the daddy.
Good luck!!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,906
Latest member
SkinfixSkintag

Latest Threads

Top