• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

File Upload Servlet

 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
All,
I am trying to upload a file via an HTTP <INPUT TYPE="FILE" NAME="file_part"> parameter using Servlets. I have downloaded the O'reilly packages, and gotten them to work ... but I am having trouble writing my own (learn by doing ). I have tried:
File f = new File ( request.getParameter ( "file_part" ) ); (which throws a NullPointerException, regardless of whether the field is populated).
AND too many hours of fruitless labor. Any suggestions? I can manipulate files fine, but I just can't GET the file
Thanks,
Ryan Lowe
 
Author
Posts: 399
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi..
Plz do a search on this forum on "file upload", go through the results, your problem would be solved by that.
hth
MB
 
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ryan,
try a BufferedReader to read the lines posted by your form.

You should find the difference between a normal form POST and an "multipart/form-data" POST.
Then you may be able to write your own multipart parser.
Regards
Torsten
 
Ryan Lowe
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you Torsten. That provided me with the direction I needed Also, Malhar ... Most of the references on JavaRanch point to the oreilly packages or other libraries, not instructions on how to do it *manually*.
Thanks Again,
R
reply
    Bookmark Topic Watch Topic
  • New Topic