• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
  • Knute Snortum
Sheriffs:
  • Liutauras Vilda
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Joe Ess
  • salvin francis
  • fred rosenberger

multipart/form-data inputs

 
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?
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • 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.
 
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?
 
Self destruct mode activated. Instructions for deactivation encoded in this tiny ad.
Sauce Labs - World's Largest Continuous Testing Cloud for Websites and Mobile Apps
https://coderanch.com/t/722574/Sauce-Labs-World-Largest-Continuous
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!