B
Ben Jessel
I have a requirement to serve a file from an internal repository, over
the web.
For example, a client request may be something like:
http://localhost:8080/repository/getFile?file_id=10
Say this retrieves a file abc.xls, my code in the getFile servlet can
quite easily set the content type to application/vnd.excel ( or
whatever it is, and serve the file ).
In order to dynamically serve up any file, I need some kind of file to
map extensions onto filenames so I can do something like
setContentType( myMappings.get(fileSuffix) );
Now, as some files do not actually have entries ( .class for example
), this list would be incomplete.
Can I get away with just not specifying a mime type? What happens in
these circumstances? Does the operating system / browser determine
what application to use?
What is the best approach here? Is it to totally disregard mime
mappings and let the client/browser pick this up?
In this instance where I am spooling bytes via an outputstream into
response.out ( the filename has been set in the header), does the
application server intervene and say "ah I can see you are spooling a
..xls file, in my web.xml mappings I see that is
application/vnd.excel...I shall set the response accordingly"? I
suspect that the mime mappings here are just used when you are
directory browing over the web.....
Does anyone have a nice cvs file of common extensions -> mime types?
the web.
For example, a client request may be something like:
http://localhost:8080/repository/getFile?file_id=10
Say this retrieves a file abc.xls, my code in the getFile servlet can
quite easily set the content type to application/vnd.excel ( or
whatever it is, and serve the file ).
In order to dynamically serve up any file, I need some kind of file to
map extensions onto filenames so I can do something like
setContentType( myMappings.get(fileSuffix) );
Now, as some files do not actually have entries ( .class for example
), this list would be incomplete.
Can I get away with just not specifying a mime type? What happens in
these circumstances? Does the operating system / browser determine
what application to use?
What is the best approach here? Is it to totally disregard mime
mappings and let the client/browser pick this up?
In this instance where I am spooling bytes via an outputstream into
response.out ( the filename has been set in the header), does the
application server intervene and say "ah I can see you are spooling a
..xls file, in my web.xml mappings I see that is
application/vnd.excel...I shall set the response accordingly"? I
suspect that the mime mappings here are just used when you are
directory browing over the web.....
Does anyone have a nice cvs file of common extensions -> mime types?