aspose file tools*
The moose likes JSP and the fly likes upload data and image at the same time Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "upload data and image at the same time" Watch "upload data and image at the same time" New topic
Author

upload data and image at the same time

jhon masco
Ranch Hand

Joined: May 13, 2010
Posts: 93
Hello
I need to send data from a form to a database but... this form have a field input also. I trying to send all the data together (image and input text values) but I can't.
Is to say in the database I just get the image but not the input text values! I read in someplace that is not possible but...I had seen that working fine in some websites!
What is wrong?
Here the code that I am -testing:
1)the jsp form:


2) and the uploadimage servlet


NOTE: the 2 values showed with System.out.print are null.

Please give me an idea.

THANKS
Stefan Evans
Bartender

Joined: Jul 06, 2005
Posts: 1016
Much as you may hate it, my suggestion would be to throw away half of this code, and use a library to parse the response for you.

The commons fileupload component is a commonly used one.
That library enables you to read both the uploaded file and the parameters sent along with it.

jhon masco
Ranch Hand

Joined: May 13, 2010
Posts: 93
Stefan Evans wrote:Much as you may hate it, my suggestion would be to throw away half of this code, and use a library to parse the response for you.

The commons fileupload component is a commonly used one.
That library enables you to read both the uploaded file and the parameters sent along with it.



Thanks Stefan
I will read about Jakarta FileUpload. Already I had seen it before but I never thinked that I would be diffcult submit values an images at the same time.
I will try these examples: example1 and example2
I hate when the examples just show how submit images and not data too!!!
If anyone know other alternative please let me know.
Gracias
sudhir nim
Ranch Hand

Joined: Aug 29, 2007
Posts: 212

You can read the other form parameters like this



Again, if you are just trying out, or if you have choice to use tomcat 7 (if you are starting a new project or just learning servlets),
Try out the @MultipartConfig and built in file upload support in servlet 3.0 Spec.
It has made life really easier, you will not need any additional library like commons file upload or any other multipart parser.


[Servlet tutorial] [Servlet 3.0 Cook Book]
jhon masco
Ranch Hand

Joined: May 13, 2010
Posts: 93
sudhir nim wrote:Again, if you are just trying out, or if you have choice to use tomcat 7 (if you are starting a new project or just learning servlets),
Try out the @MultipartConfig and built in file upload support in servlet 3.0 Spec.
It has made life really easier, you will not need any additional library like commons file upload or any other multipart parser.


Thanks Sudhir
Nice tips specially @MultipartConfig. I will continue trying fileupload library while I change to tomcat 7.
Also I had found other good tips here if anyone need help must check the link.

Thank you very much.
jhon masco
Ranch Hand

Joined: May 13, 2010
Posts: 93
Hi again
Here the solution using jakarta fileupload library

Luck! and thanks
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: upload data and image at the same time
 
Similar Threads
problem in uploading a file
image error java.io.FileNotFoundException:
error in uploading zip file
Problem with uploading images
uploading the content of a .csv file in database