• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 436
  • Last Modified:

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
0
Web_Admin
Asked:
Web_Admin
  • 5
  • 5
1 Solution
 
for_yanCommented:
0
 
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 ?
0
 
for_yanCommented:
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
0
Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

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


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)

http://wiki.eclipse.org/Jetty/Howto/Install_Jetty

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


0
 
Web_AdminAuthor Commented:
for_yan:

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
0
 
for_yanCommented:
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.  
0
 
Web_AdminAuthor Commented:
what about saving the files into database ? would not make it easier to retrieve them without relyaing in third party ?
0
 
for_yanCommented:
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.
0
 
Web_AdminAuthor Commented:
Thanks :)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

  • 5
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now