File upload with JSP

Hello experts,

I need to submit a form to a jsp page, the form include file + some other information like first name , email address .. ect

I need to know the best approcah to achiev this . I would buy a library if thats needed
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Web_AdminAuthor Commented:
I wana submit data along with the file. if i add this attribute mulitpart/form-data to the form, i won't be able to read the submitted data.. am I wrong ?
You certainly can submit regular values, lke strings along with file as part of
multi-part form - I do it in servlet environemnt all the time
Become a CompTIA Certified Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

Web_AdminAuthor Commented:
Then what the more convenitent place to store the files: folder or database?

I am not sure how your last question relates to the beginnig about JSP.

If you are asking about how to store files on the server side after upload,
I guess both methods are possible - it depends how you are going to use them.

In my applications for example I used the data from the uploaded file
to create a GIF file to show it to the user on the next page, and those
I placed in more or less temporary folder on the server.

Simultaneously I stored the original text files
as CLOBs in Oracle for long term future use

I am actually dealing with MultiPart form it using Jetty HTTP library which had MultiPartRequest class (see code example below)

I thought that since I was implemnting it, it is now
part of standard HTTPServlet, but if it is, not Jetty is very simple to use:

import com.mortbay.HTTP.*;


MultiPartRequest mpr = new MultiPartRequest(req);

   String login_name = mpr.getString("login_name");


   String project = mpr.getString("project_name");

  DataInputStream input = new DataInputStream(mpr.getInputStream("fileName"));

.... read file from input stream

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Web_AdminAuthor Commented:

I am looking for the best approcah to upload file using jsp.. for example to submit form with your information and a copy of your passport or cv.. my boss asked me to look for best way to implement this

I hope it is clear now
In this case I'd probably store meta data for the applicants (first name, last name, etc)
in the database table, and their CVs you may store in some folder and keep URLs to that
files in the database in the same table.
That would allow you easier access to CVs, say when you want to print
some of them or view them quickly without using special application.  
Web_AdminAuthor Commented:
what about saving the files into database ? would not make it easier to retrieve them without relyaing in third party ?
If you are interested in long-time safe storage then databse is probably better,
for easy retrieval - if you put them into one folder and name them reasonably, say starting with
the last name, that would probably be easier. If you store them in database, as LOB
you'll then have to write application or web page to show them and this application
will be the main way to view them.
Anyway, those are my preferences, I think both ways a feasible.
Web_AdminAuthor Commented:
Thanks :)
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.