aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes FIle Upload from Client to Server Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of JavaScript Promises Essentials this week in the JavaScript forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "FIle Upload from Client to Server" Watch "FIle Upload from Client to Server" New topic
Author

FIle Upload from Client to Server

Nair Anoop
Ranch Hand

Joined: May 09, 2001
Posts: 68
Hi All,
I have written a small EJB and JSP which uploads some user info from a form to the DB. I would also like to upload a file from the user to the server.
Any ideas / resources on how this can be done ?
Thanks.
Anoop
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

In my company this is known as "the file upload problem".

To perform file uploads, you use a different type of form encoding (offhand it's called multipart/form-data). This means that the handy request.getParameter("xxx"); won't work!

Also problematic is the habit of some app servers (namely iPlanet!) to attempt to parse this kind of form data into name value pairs, and failing, to throw the data away.

However, if you use a 'normal' server (one that isn't buggy in this respect), I'd suggest using the oreilly classes.
http://www.servlets.com/cos/index.html
Sergei Voropay
Ranch Hand

Joined: Feb 20, 2001
Posts: 31
Instead of writing all the code to deal with multipart form data you probably better off using prebuilt components available from different vendors. Some application servers supply their own classes/components designed specifically for that purpose (i.e. Orion supplies FilePostParser and PostFileInputStream to work with multipart data). You could also use either classes available from o'reilly or a tag-lib from jspSmart.com (jspSmartUpload).
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: FIle Upload from Client to Server