File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes Cannot recognize conten type = Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Cannot recognize conten type = "multipart/form-data" in JSP" Watch "Cannot recognize conten type = "multipart/form-data" in JSP" New topic

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

cho con

Joined: Apr 02, 2010
Posts: 26
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

Joined: Sep 29, 2008
Posts: 12617

Without the code that handles the request it's impossible to help.
cho con

Joined: Apr 02, 2010
Posts: 26
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

Joined: Jan 10, 2002
Posts: 63862

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".

[Asking smart questions] [About Bear] [Books by Bear]
cho con

Joined: Apr 02, 2010
Posts: 26
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:
subject: Cannot recognize conten type = "multipart/form-data" in JSP
It's not a secret anymore!