tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From André Warnier ...@ice-sa.com>
Subject Re: Problem moving from file upload servlet to JSP
Date Mon, 19 Apr 2010 21:51:55 GMT
Christopher Schultz wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> André,
> 
> On 4/19/2010 5:19 PM, André Warnier wrote:
>> Ken Bowen wrote:
>> ...
>>
>>> Long form.  Here's the html for file upload (vanilla):
>>>
>>> <form name="csvUploadForm" action="csvfileupload" method="post"
>>> enctype="multipart/form-data">
>>>     File:<input type="file" name="csvfile2upload"><br></br>
>>>     <input type="submit" name="Submit" value="Upload CSV File"
>>> onclick="uploadCSVFile();return false;">
>>> </form>
>>>
>> Without and before getting to the Java stuff, I do not really understand
>> why above you have a button of type "submit", but with an "onClick"
>> event triggering a javascript function.
>> Either the button should be of type "button" and have an onClick event
>> handler, or it should be of type "submit" and not have an event handler.
> 
> An exception is the case where you want a page that works both with and
> without Javascript enabled: the <input type="submit"> allows the form to
> submit in the standard way when no Javascript is present, but allows the
> (presumably mind-blowingly fantastic) Javascript alternative to run when
> appropriate.
> 
> You can't get this behavior from type="button".
> 
>> I suspect that by specifying both, you may be generating 2 actions and
>> confusing the browser and/or the receiving end.
> 
> The "return false;" at the end of the trigger indicates that the event
> handler will (duh) return false. When that happens, the browser is
> supposed to basically drop the event and not send it to the "default"
> handler, which would result in the form being submitted in the
> traditional way. This is actually a pretty standard Javascript
> implementation.
> 
Ok, I'll accept that explanation.
Which still leaves us in the dark concerning the content of that 
javascript uploadCSVFile() function which is probably the one used in 
this case then to post the form content to the server.
I must admit I still don't see the need of it in this case, since the 
form as it is without the onClick would submit the file just as well.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message