This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Other JSE/JEE APIs and the fly likes File Upload Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "File Upload" Watch "File Upload" New topic
Author

File Upload

ruba sampath
Greenhorn

Joined: Jun 17, 2011
Posts: 28
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
Haina Minawa
Ranch Hand

Joined: Oct 13, 2011
Posts: 119
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

Joined: Jun 17, 2011
Posts: 28
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.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19651
    
  18

Check out Apache Commons FileUpload.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Haina Minawa
Ranch Hand

Joined: Oct 13, 2011
Posts: 119
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:

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: File Upload
 
Similar Threads
Junk characters in field after submitting
problem with multipart/form-data
Action form is not populated while using html:form enctype="multipart/form-data"
Uploading Files
Uploading Single File by Using enctype="multipart/form-data"