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

Cannot recognize conten type = "multipart/form-data" in JSP

 
cho con
Greenhorn
Posts: 26
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I have the trouble that JSP cannot recognize the "multipart/form-data" then I cannot upload the file on server, here is my code, could you please see for me



The action in the form here is empty and the the submission of this form will be manage by


with the value = "finish" then servlet will navigate to another page (this code I put in doPost method, I often do like this and everything is ok, so I think it's not the problem from the empty action in form). But when I navigate to a page which has a piece of code:



and the result was that it is not a "multipart/form-data". I really frustrate with this problem since I cannot do any thing with my project, I have to upload the file on server, but it cannot recognize the form as a multipart/form-data and I get stuck at this step, could you please help me? I greatly appreciate your help! Thanks a lot



 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Without the code that handles the request it's impossible to help.
 
cho con
Greenhorn
Posts: 26
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is the code that handles request:




And the following is a piece of code in file Upload.jsp. From this statement, it shows that the previous form is not multipart/form-data


 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64205
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why aren't you handling the multi-part parsing in the servlet? Java in a JSP is an egregious violation of best practices.

Also, getParameter() will not work with multi-part requests.

And, please take the time to carefully enter your posts. "content type" not "conten type".
 
cho con
Greenhorn
Posts: 26
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually I don't use getParameter() method, I am new to JSP and I found some code example for upload file, it works fine, but when I integrate to my part, it didn't recognize the "multipart/form-data". The attached files are the code that I got with a simple text input, 2 controls of file input and it can upload, I didn't change any thing except that put more controls (aligned in a table that devided into 2 parts) and use the empty action form. Finally, I don't understand what the problem from?
This is the upload html



This is the upload jsp

 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic