Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Servlet File Upload and JQuery as his brothers

 
J. Insi
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


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
Posts: 212
Eclipse IDE Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65225
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).
 
J. Insi
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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....
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic