File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Setting Content - Boundary in a XMLHttpRequest object

 
karthik Suryanarayanan
Ranch Hand
Posts: 121
Java Opera Oracle
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ?

 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64178
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ajax cannot be used for file uploads.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64178
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
(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
Posts: 121
Java Opera Oracle
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 .
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic