Results 1 to 1 of 1
Thread: Ajax / servlet File upload
- 06-08-2010, 02:48 PM #1
Member
- Join Date
- Jun 2010
- Posts
- 1
- Rep Power
- 0
Ajax / servlet File upload
Hi all!
I'm trying to implement a simple file upload to the server, but i've a little problem.
I've created a web interface with a form where i insert my data, and an input type="file" to select a file from my disk.
When i click on the button to send the request, i set the parameters to be passed via method post, and i do the:
serv.open("POST","myServlet",true); and i send the parameters with serv.send(parameter's list).
In my servlet i save and use them with the request.getParameter("parameterName).
This works rigth if i set the header in this way:
serv.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
There is a class in java that helps in uploading files, but i've to set the content-type to: multipart/form-data
So i've changed the setRequest in this way:
serv.setRequestHeader('Content-Type', ' multipart/form-data');
But now, in the servlet, i'm not able to take the parametes passed in the serv.send()...i have a null pointer exception.
If i change again the content-type like before, and i try to save the file on server, i have this error:
Posted content type isn't multipart/form-data.
Any ideas?
Anybody can help me?
Similar Threads
-
:large file upload to server(chunk upload)
By tommy_725 in forum NetworkingReplies: 0Last Post: 10-16-2009, 12:21 AM -
upload and download file using servlet
By amit_m04 in forum Java ServletReplies: 1Last Post: 09-27-2009, 03:06 AM -
Upload file to servlet and pass file to another servlet
By hofsoc in forum Advanced JavaReplies: 6Last Post: 06-04-2009, 11:09 PM -
File Upload Servlet problem
By jeniramires in forum Advanced JavaReplies: 3Last Post: 08-18-2008, 07:34 PM -
how to upload a file using servlet
By simon in forum Java ServletReplies: 1Last Post: 08-05-2007, 03:50 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks