This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes Setting Content - Boundary in a XMLHttpRequest  object Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Setting Content - Boundary in a XMLHttpRequest  object" Watch "Setting Content - Boundary in a XMLHttpRequest  object" New topic
Author

Setting Content - Boundary in a XMLHttpRequest object

karthik Suryanarayanan
Ranch Hand

Joined: Oct 07, 2009
Posts: 110

Hi Guys,
Please help me out how to set content boundary for the Content-Type ( multipart/form-data ) in the setRequestHeader method of XMLHttpRequest object . I have two forms in my jsp wherein i use one form for making an Ajax call to upload a file while my other form carries all the input fields which are being used in my mvc architecture.

Without setting RequestHeader in XMLHttpRequest object , is there a way where content type reaches my servlet ?

How do normal forms submit contenttypes and headers by default to Servlets ?


"Learning is a Culture where your Eagerness & Curiosity plays a major Role".
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60082
    
  65

Ajax cannot be used for file uploads.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60082
    
  65

(If you are using jQuery and its form plugin, it can appear as if it can, but jQuery is using an iframe behind the curtain.)
karthik Suryanarayanan
Ranch Hand

Joined: Oct 07, 2009
Posts: 110

I just used a seperate JSP which contains only form where ENCTYPE i have declared as multipart/form-data and submitted the entire page to a servlet rather than an Ajax call. This solved my problems of getting content type & bounday values properly .
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Setting Content - Boundary in a XMLHttpRequest object
 
Similar Threads
Struts2 & XmlHttpRequest & input_file & Html5
How to set unique boundary string in MimeMultipart?
RPC SOAP Client in Javascript
Passing the JSON Array to the servlet
SAAJ (SOAP 1.1) incompatibility with Java 1.6