Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Get MIME type of file returns application/octet-stream for all but txt

843789Apr 27 2010
Eclipse 3.3.1.1, JRE 1.6.0_03, Tomcat 6.0, webwork 2.2.4
I've created a test upload/view file page. I can successfully upload and return the file to view. However, the content type is always application/octet-stream except for txt.
String contentType = new MimetypesFileTypeMap().getContentType(filename);
System.out.println("contenttype for " + filename + ": "+contentType);
I created mime.types in my META-INF for tomcat and populated it, but it doesn't change anything. Uploading an mp3 should return the audio/mpeg3 I have in mime.types:
audio/mpeg3 mp3
I verified that it is in /wtpwebapps/MyApp/META-INF/

My web.xml even has it:
    <mime-mapping>
        <extension>mp3</extension>
        <mime-type>audio/mpeg3</mime-type>
    </mime-mapping>
Am I missing something?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 25 2010
Added on Apr 27 2010
0 comments
823 views