This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes Servlets and the fly likes POST data with a file upload 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 » Servlets
Bookmark "POST data with a file upload " Watch "POST data with a file upload " New topic
Author

POST data with a file upload

Christopher Jursa
Greenhorn

Joined: Jul 19, 2004
Posts: 4
Hello,

I am attempting to make a POST request to another servlet with a file upload. I have the code below but it is not working properly. I posted this in the servlet forum as I am trying to use one servlet to contact another.

I think all but the file writing is ok. The other data being written are all string fields and should be correct.

The service that I am posting to works fine. I have tested it independently with success. However, I can't seem to send the file and other through this code.

I actually don't need to pass the file. I have code that reads the file into a variable that can be passed.

However, I need to emulate the multipart form. How do I emulate the multipart form.

Can anyone verify that I am doing this correctly?



[ November 22, 2006: Message edited by: Christopher Jursa ]
[ November 22, 2006: Message edited by: Christopher Jursa ]
Christopher Jursa
Greenhorn

Joined: Jul 19, 2004
Posts: 4
I should add, the exception thrown by the servlet I am trying to contact is "Posted content type isn't multipart/form-data".
 
jQuery in Action, 2nd edition
 
subject: POST data with a file upload
 
Similar Threads
Upload File on a web Server From client application
Upload File on a web Server From client application
post request to url
Simple Question - AJAX and JAVA, Is It Possible?
error while submitting an http web request