Servlet Design Question

Discussion in 'Java' started by Rhino, Jul 28, 2003.

  1. Rhino

    Rhino Guest

    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.

    --

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

  2. Rhino

    VisionSet Guest

    "Rhino" <> wrote in message
    news:yj9Va.2050$...
    > [....]
    > 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!!

    --
    Mike W
    VisionSet, Jul 28, 2003
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Andy Fish
    Replies:
    4
    Views:
    2,396
    Andy Fish
    Dec 17, 2003
  2. Sean Clarke
    Replies:
    1
    Views:
    1,876
    Sudsy
    Jan 7, 2004
  3. circuit_breaker
    Replies:
    2
    Views:
    1,978
    Jack Jia
    Apr 4, 2004
  4. chamikara
    Replies:
    1
    Views:
    49,827
  5. dave
    Replies:
    5
    Views:
    579
    William Brogden
    Jul 17, 2004
Loading...

Share This Page