• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Junilu Lacar
  • Liutauras Vilda
Sheriffs:
  • Paul Clapham
  • Jeanne Boyarsky
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
Bartenders:
  • Jesse Duncan
  • Frits Walraven
  • Mikalai Zaikin

multipart/form-data inputs

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
pie. tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic