5.12. Associating Files with MIME Types

Servers typically have a way for Webmasters to associate file extensions with media types. So, for example, a file named mom.jpg would automatically be given a MIME type of image/jpeg. However, suppose that your Web application has unusual files that you want to guarantee are assigned a certain MIME type when sent to clients. The mime-mapping element, with extension and mime-type subelements, can provide this guarantee. For example, the following code instructs the server to assign a MIME type of application/x-fubar to all files that end in.foo.

<mime-mapping> 
  <extension>foo</extension> 
  <mime-type>application/x-fubar</mime-type> 
</mime-mapping> 

Or, perhaps your Web application wants to override standard ...

Get More Servlets and JavaServer Pages™ now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.