• 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

getting the details of the file from the servlet

 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic