• 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:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

File Upload

 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

I am using "multipart/formdata" in my JSP page to reterive the file as an object. But i am using text fields as well as check box, radio button in my form. After submitting my form only the upload file contain the value. Othe fields are getting null. I think this is because of enctype. How to resolve it to get all the fields value slong with file type values in my servlet.

Thanks
 
Ranch Hand
Posts: 119
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

ruba sampath wrote:Hi

I am using "multipart/formdata" in my JSP page to reterive the file as an object. But i am using text fields as well as check box, radio button in my form. After submitting my form only the upload file contain the value. Othe fields are getting null. I think this is because of enctype. How to resolve it to get all the fields value slong with file type values in my servlet.

Thanks



The exact value for enctype is "multipart/form-data", and you should use type="file" for the input tag. Here is an example:

 
ruba sampath
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

Thanks for the sample. I am already doing like this only. but the problem here is i am using text as well as checkbox in my form. i m not getting value for that if i use request.getParameter(), because i m using multipart/formdata in my form. HOW TO RESOLVE THIS?

THANKS.
 
Sheriff
Posts: 22857
132
Eclipse IDE Spring Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Check out Apache Commons FileUpload.
 
Haina Minawa
Ranch Hand
Posts: 119
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

ruba sampath wrote:Hi

Thanks for the sample. I am already doing like this only. but the problem here is i am using text as well as checkbox in my form. i m not getting value for that if i use request.getParameter(), because i m using multipart/formdata in my form. HOW TO RESOLVE THIS?

THANKS.



request.getParameter() returns null for multipart/form-data, so you have to retrieve the value from the FileItem object instead. Here is an example:

 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic