File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/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


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "File upload servlet" Watch "File upload servlet" New topic
Author

File upload servlet

omkar patkar
Ranch Hand

Joined: Aug 25, 2005
Posts: 231
Hi Friends,

I have made an html page through which the user can browse a file on his local machine and submit to a servlet. But, now i am stuck, at the point as to how i will get the file as data in my servlet ? .... i tried to google for file upload servlets, but majority of the links talked about MIME parsers, Multipart handlers, readymade servlets etc., ...but no where i got information on the very basic way of accessing the file data that the servlet will receive in request...how it can be used? ....how to access the file data? ....how to know the type of file being uploaded? .... how to know the size of the file being uploaded....etc.,

Please someone help me by guiding the very basics of this concept....file uploading and servlets

Million thanks in advance


Thanks and Regards
Omkar Patkar (SCJP 1.4)[url]http://javacollectionsnotes.blogspot.com[/url] | [url]http://omkar-myscjpexp.blogspot.com[/url]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61417
    
  67

There is an entry on file uploading in the How To section of the JSP FAQ.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
omkar patkar
Ranch Hand

Joined: Aug 25, 2005
Posts: 231
Thank you Bear...but the FAQ also talks about ready made libraries to be used. I want to know what exactly are the problems that can be faced by developers who develop servlets...for such purposes. May be i can re-invent the wheel! ...

Where can i get the detail information at the most basic level ?...pls ?

Thanks and Regards
Omkar Patkar
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61417
    
  67

Originally posted by omkar patkar:
Where can i get the detail information at the most basic level ?...pls ?

Please be sure to use real words, not abbreviations like "pls" when posting to the forums.

If you want to re-invent the wheel as an academic exercise, then look up "multipart request". File upload requests do not have the same format as "normal" requests, and you must parse them yourself.
omkar patkar
Ranch Hand

Joined: Aug 25, 2005
Posts: 231
Apologies for using abbrevations ...ok will try to search and get some info that way....thank you BEAR!

mkar Patkar
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61417
    
  67

No need to apologize -- the guideline is there to help you get better responses.

You might want to download one of the 3rd-party libraries to see how they did it in addition to any other information you find.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: File upload servlet