• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Junilu Lacar
  • Liutauras Vilda
Sheriffs:
  • Paul Clapham
  • Jeanne Boyarsky
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
Bartenders:
  • Jesse Duncan
  • Frits Walraven
  • Mikalai Zaikin

upload data and image at the same time

 
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Bartender
Posts: 1845
10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 98
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
 
Ranch Hand
Posts: 212
Eclipse IDE Spring Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
jhon masco
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 98
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi again
Here the solution using jakarta fileupload library

Luck! and thanks
 
Politics is a circus designed to distract you from what is really going on. So is this tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic