On Wed, 20 Nov 2002, Poynter, Stephen wrote:

> I have just written a document upload tool for a customer using the struts
> upload functionality.  My upload jsp consists of one form that is of course
> a multipart/form-data form.  The form consists of the file field along with
> other text fields where the user enters various information( owner, title,
> etc.) about the file to be uploaded.  The problem I'm having is that once
> you submit the form struts immediately starts uploading the file before any
> of the other data in the form is validated.  So, in my case, the user tries
> to upload a large file but enters invalid information for the other text
> fields.  Struts then uploads the file before validating the form data.  So
> when the user corrects their mistake they have to re-upload the file yet
> again.  Is it possible to have the form data validated before the file is
> uploaded?  I would rather not use javascript for error checking.  Any help
> is appreciated.  Thanks...

Just to clarify the process, Struts does not upload the file, the browser
does. The file is part of the same request as the other fields in your
form - it's one of the -parts- in the -multipart- request, as is each of
the remaining fields. Struts can't start working on the request until it
is complete, including the file upload.

If you need to do validation before the file is uploaded, you either need
to use JavaScript in the browser, or use a separate page for the other
fields, so that you can validate them server-side before the file is
uploaded from its own page.

--
Martin Cooper


>
> Steve
>
>
> --
> To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
>
>


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to