File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes multipart/form-data inputs Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "multipart/form-data inputs" Watch "multipart/form-data inputs" New topic
Author

multipart/form-data inputs

Stephen ODonnell
Greenhorn

Joined: Sep 07, 2004
Posts: 19
Hi all,

I am trying to upload a file using a jsp page but I am having a problem with multipart/form-data. It doesn't seem to find some of my input parameters!!



When I try the above code 'mydesc' can be found in the http request but not 'name' and 'filename' and I swap the code around (see below) I can see 'name' and 'filename' but not 'mydesc'.


Does anyone know what is wrong?
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

How are you trying to retrieve the parameters?

request.getParameter() doesn't work with multipart forms. You need to use the methods provided by the upload libraries you are using.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Stephen ODonnell
Greenhorn

Joined: Sep 07, 2004
Posts: 19
Hi Ben,

Thanks for your reply. This is the code i'm using get the parameter from the request:





But when I print out the line passed into getDispositionInfo(), I either get

form-data; name="name"; filename="C:\reports\Monthly.rpt"[B]

or

[B]form-data; name="mydesc"


depending on which order they are in, in the Jsp.
Is there a handy any of logging to file all the contents of the request?

Thanks,
Stephen.
Dan Novik
Ranch Hand

Joined: Jan 26, 2005
Posts: 39
Check out this for example:

http://www.servletsuite.com/servlets/uptag.htm
Stephen ODonnell
Greenhorn

Joined: Sep 07, 2004
Posts: 19
Hi all,

Thanks for your help. I've used tag-lib method. But i've run into a strange problem. I am doing the upload to tomcat as follows:



I get the contextPath which is /myreports however the report gets saved as number and not the proper file name.

When I hardcode the path every thing works fine. Ideally I want to save the reports in contextPath/Reports i.e myreports/Reports

Has anyone had this problem?? What am I doing wrong?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: multipart/form-data inputs
 
Similar Threads
Ajax javascript not recieving responseText from Struts
Problem in Selecting values from select tag
How to get a scriptlet value for javascript validation
Horizontal scrollbar problem
tiles and <sx:autocompleter>