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

getting the details of the file from the servlet

farhath farook
Ranch Hand

Joined: Aug 01, 2007
Posts: 37
hi i want to get a uploaded file and its related details from a servlet.(such as type of file ,mime type) if i can get that response as a File object i can get it . but what i get from 'response.getInputStream' is sort of input stream .

so please can anyone tell me how to get the file name, MIME type . length of the uploaded file.
thanks in advance.
Patel Chintan
Ranch Hand

Joined: Mar 01, 2007
Posts: 80
Originally posted by farhath farook:
hi i want to get a uploaded file and its related details from a servlet.(such as type of file ,mime type) if i can get that response as a File object i can get it . but what i get from 'response.getInputStream' is sort of input stream .

so please can anyone tell me how to get the file name, MIME type . length of the uploaded file.
thanks in advance.


Hi farhath,
for uploading and retrivin its MIME type you can visit this link:
http://www.developershome.com/wap/wapUpload/wap_upload.asp?page=jsp3


and for Diifferent kind MIME type :
http://www.iangraham.org/books/html4ed/appb/mimetype.html


Chintan Patel, SCJP1.5, http://datewithjava.blogspot.com
farhath farook
Ranch Hand

Joined: Aug 01, 2007
Posts: 37
yes thanks. but the problem is that i want it to save in my jackrabbit repository . so i need its MIME type and the file as an instance of InputStream
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Originally posted by farhath farook:
.. but what i get from 'response.getInputStream' is sort of input stream .


I assume you mean request.getInputStream.

In any case, most of us don't write our own parsers for dealing mulit-part requests (uploads). Typically, this is done with a library such as Jakarta Commons FileUpload. These libraries have methods for getting things like the file name.

See:
http://faq.javaranch.com/java/FileUpload for links to some of the more popular ones.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: getting the details of the file from the servlet