Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

multipart/form-data inputs

 
Stephen ODonnell
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Stephen ODonnell
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check out this for example:

http://www.servletsuite.com/servlets/uptag.htm
 
Stephen ODonnell
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic