aspose file tools*
The moose likes Servlets and the fly likes File Upload Servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "File Upload Servlet" Watch "File Upload Servlet" New topic
Author

File Upload Servlet

Ryan Lowe
Greenhorn

Joined: Aug 04, 2003
Posts: 18
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
Malhar Barai
Author
Ranch Hand

Joined: Aug 17, 2001
Posts: 399
hi..
Plz do a search on this forum on "file upload", go through the results, your problem would be solved by that.
hth
MB
Torsten Schippel
Ranch Hand

Joined: May 09, 2003
Posts: 62
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

Joined: Aug 04, 2003
Posts: 18
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: File Upload Servlet