• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

getting the details of the file from the servlet

 
farhath farook
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
farhath farook
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic