-
Servlets, HTML forms, multipart/form-data (5 messages)
- Posted by: Sean Sullivan
- Posted on: October 15 2002 23:16 EDT
When I submit this form, the FooServlet receives an HttpServletRequest with a Content Type value of multipart/form-data
The problem is that the "submitter" attribute and the "serviceClass" attribute are not set. The servlet has no way to read the serviceClass value.
Perhaps the web browser does not send the serviceClass parameter in the HTTP request?
Any advice?
The client web browser is Internet Explorer 6.0 SP1
<FORM ACTION="/servlet/FooServlet"
ENCTYPE="multipart/form-data"
METHOD=POST>
What is your name? <INPUT TYPE=TEXT NAME=submitter><br>
What file are you sending? <INPUT TYPE=FILE NAME=secretDocument><br>
<input type=hidden name="serviceClass" value="FoobarServiceMgr">
<input type="submit" value=Submit><br>
</FORM>
Threaded Messages (5)
- Servlets, HTML forms, multipart/form-data by Sean Sullivan on October 16 2002 15:33 EDT
- Servlets, HTML forms, multipart/form-data by Borislav Iordanov on October 19 2002 12:16 EDT
- Servlets, HTML forms, multipart/form-data by Dharmanand Singh on October 28 2004 06:04 EDT
- How to invoke and use getParameter for getting parametrs from req by pooja jain on January 31 2012 05:24 EST
- How to invoke and use getParameter for getting parametrs from req by pooja jain on January 31 2012 05:22 EST
-
Servlets, HTML forms, multipart/form-data[ Go to top ]
- Posted by: Sean Sullivan
- Posted on: October 16 2002 15:33 EDT
- in response to Sean Sullivan
Situation:
javax.servlet.HttpServletRequest.getParameter(String) returns null when the ContentType is multipart/form-data
Solutions:
Solution A:
1. download http://www.servlets.com/cos/index.html
2. invoke getParameters() on com.oreilly.servlet.MultipartRequest
Solution B:
1. download http://jakarta.apache.org/commons/sandbox/fileupload/
2. invoke readHeaders() in
org.apache.commons.fileupload.MultipartStream
Solution C:
1. download http://users.boone.net/wbrameld/multipartformdata/
2. invoke getParameter on
com.bigfoot.bugar.servlet.http.MultipartFormData
Solution D:
1. Use Struts. Struts 1.1 handles this automatically
-
Servlets, HTML forms, multipart/form-data[ Go to top ]
- Posted by: Borislav Iordanov
- Posted on: October 19 2002 12:16 EDT
- in response to Sean Sullivan
Solution E: use TICL (www.kobrix.com), it handles it automatically too...;) -
Servlets, HTML forms, multipart/form-data[ Go to top ]
- Posted by: Dharmanand Singh
- Posted on: October 28 2004 06:04 EDT
- in response to Sean Sullivan
There is also a better way for the Solution B (easy to use). The steps involved are as follows:
1. Download one of the versions of UploadFile from http://jakarta.apache.org/commons/fileupload/
2. Invoke parseRequest(request) on org.apache.commons.fileupload.FileUploadBase which returns list of org.apache.commons.fileupload.FileItem objects.
3. Invoke isFormField() on each of the above FileItem objects. This determines whether the file item is a form paramater or stream of uploaded file.
4. Invoke getFieldName() to get parameter name and getString() to get parameter value on FileItem if it's a form parameter. Invoke write(java.io.File) on FileItem to save the uploaded file stream to a file if the FileItem is not a form parameter. -
How to invoke and use getParameter for getting parametrs from req[ Go to top ]
- Posted by: pooja jain
- Posted on: January 31 2012 05:24 EST
- in response to Dharmanand Singh
I have downloaded multipartrequest.jar and cos.jar and put it into WEB-INF lib folder.
Now how to invoke getParameter in my jsp page?
I have created 1 jsp "main.jsp" in which there is a form
like
<form action="upload.jsp" method="post" enctype="multipart/form-data">....input fileds with upload file data..</form>
Now on upload.jsp through "org.apache.commons.fileupload" I have saved my uploaded file into server + here I want to get the other fields from "main.jsp" and insert them into database(mysql)
As I was using multipart,it was inserting null values to db, nw as per 1 of ur solution
I have downloaded multipartrequest.jar and cos.jar and put it into WEB-INF lib folder.Now how to invoke getParameter in my jsp page?
Response will be appriciated.
-
How to invoke and use getParameter for getting parametrs from req[ Go to top ]
- Posted by: pooja jain
- Posted on: January 31 2012 05:22 EST
- in response to Sean Sullivan
I have downloaded multipartrequest.jar and cos.jar and put it into WEB-INF lib folder.
Now how to invoke getParameter in my jsp page?
I have created 1 jsp "main.jsp" in which there is a form
like
....input fileds with upload file data..Now on upload.jsp through "org.apache.commons.fileupload" I have saved my uploaded file into server + here I want to get the other fields from "main.jsp" and insert them into database(mysql)
As I was using multipart,it was inserting null values to db, nw as per 1 of ur solution
I have downloaded multipartrequest.jar and cos.jar and put it into WEB-INF lib folder.Now how to invoke getParameter in my jsp page?
Response will be appriciated.