brad211987
02-01-2008, 09:38 PM
Does anyone know of any utilities that can give you the http content type of a file based on its extension? I couldn't find anything in the javadocs and google hasn't been very much help for me so far.
What I'm looking to do is take a file, for example a pdf file: myfile.pdf. Look at the extension and know to set the content type on the http response to "application/pdf" or "application/msword" for word docs etc....
I can do this, but I cannot find a way to do it dynamically without writing an individual case for any document type I want to support. That just seems like an ugly way to handle it.
What I'm looking to do is take a file, for example a pdf file: myfile.pdf. Look at the extension and know to set the content type on the http response to "application/pdf" or "application/msword" for word docs etc....
I can do this, but I cannot find a way to do it dynamically without writing an individual case for any document type I want to support. That just seems like an ugly way to handle it.