aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes Servlet File Upload and JQuery as his brothers Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Servlet File Upload and JQuery as his brothers" Watch "Servlet File Upload and JQuery as his brothers" New topic
Author

Servlet File Upload and JQuery as his brothers

J. Insi
Ranch Hand

Joined: Aug 11, 2010
Posts: 90


Hello everyone...!!

dreng, dreng, dreeeng...!! Heheh, I have 1 servlet to handle the posted form of multipart/form-data

and then it will eventually do the work uploading the file from a file chooser.
Well basically, here's my servlet that works!



But, here comes the thing.
When I want to put jquery to request this servlet. I have no idea how the jquery do a "post" with multipart/form-data enctype. OMG. is there any clue of it?
sudhir nim
Ranch Hand

Joined: Aug 29, 2007
Posts: 212

The question belongs javascript forum and not servlets.

If you want to know how to submit a form using javascript
- You can call the .submit() method on your form.

If you want to do it with ajax
- Files can not be uploaded using ajax, but there are some alternatives and there are some jquery plugins that would do it for you. just search for jquery file upload plugin.


[Servlet tutorial] [Servlet 3.0 Cook Book]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61761
    
  67

Unless I am remembering incorrectly, the jQuery Forms plugin will automatically handle the form via an iframe when a file upload is needed (as Ajax cannot handle file uploads).


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
J. Insi
Ranch Hand

Joined: Aug 11, 2010
Posts: 90
sudhir nim wrote:The question belongs javascript forum and not servlets.

If you want to know how to submit a form using javascript
- You can call the .submit() method on your form.

If you want to do it with ajax
- Files can not be uploaded using ajax, but there are some alternatives and there are some jquery plugins that would do it for you. just search for jquery file upload plugin.


o, yeah. That .submit() method is of course work for javascript.
hehee, belongs to javascript forum not servlet eh? Well, at least I got some words here.

Well anyway, I wouldn't use the ajax to do uploading either.
Because before this, i do manual 2 jsp page; 1) for file Upload Form 2) for Servlet File Upload Processing
and that one works using multipart that I mentioned earlier...

it just like, if I put jquery instead of the normal posting (changing page),
I wonder if I shall put the jquery once the button is clicked and yes, it would eventually request the servlet from 2nd jsp...

but, are you guys also have tried to post using multipart, something like that?
J. Insi
Ranch Hand

Joined: Aug 11, 2010
Posts: 90
because...

I finally found out the code from php coders
to handle the Jquery upload ... but this one is handled by the php


I wonder how could we obtain it in JSP?
JQuery File Upload for PHP

in PHP i saw at the source code file name upload.php that they provide
it call $_FILES as the Variable that contained the file passed over the request.

How about in JSP, is there anything that similar to it? I am confused....
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Servlet File Upload and JQuery as his brothers