Friday, May 29, 2015

WebLogic mime mappings

To configure mime-mappings in WebLogic, you have 2 ways.
One is to configure the whole domain, with a mimemappings.properties file.
This is the entry in config.xml (you can do it in console, domain, webapplications):

 <web-app-container>
    <x-powered-by-header-level>NONE</x-powered-by-header-level>
    <mime-mapping-file>./config/mimemappings.properties</mime-mapping-file>
  </web-app-container>


Mime Mapping File 

Returns the name of the file containing mime-mappings for the domain.

Format of the file should be: extension=mime-type

Example:
htm=text/html
gif=image/gif
jpg=image/jpeg

If this file does not exist, WebLogic Server uses an implicit mime-mapping set of mappings defined in weblogic.utils.http.HttpConstants (DEFAULT_MIME_MAPPINGS). To remove a mapping defined in implicit map just set it to blank.

MBean Attribute:
WebAppContainerMBean.MimeMappingFile




The other way is to create a mime-mapping entry in your web application's web.xml

For a general presentation of IE11 and Mime: https://msdn.microsoft.com/en-us/library/ms775148%28v=vs.85%29.aspx

Remember also the default-mime-type attribute in weblogic.xml. "This element allows the user to specify the default mime type for a content-type for which the extension is not mapped."



2 comments:

Michael said...

Thanks for the helpful post. I used the web.xml approach, since I was more confident that I knew what I was doing there, but I hadn't thought of editing the file until you suggested it. Just in case someone else down the road needs a concrete example, here are the mappings I added to our web.xml file:

<mime-mapping>
    <extension>css</extension>
    <mime-type>text/css</mime-type>
</mime-mapping>
<mime-mapping>
    <extension>js</extension>
    <mime-type>text/javascript</mime-type>
</mime-mapping>
<mime-mapping>
    <extension>XML</extension>
    <mime-type>text/xml</mime-type>
</mime-mapping>

Michael said...

... and we needed additional mappings for jpeg, gif and png extensions. (All necessitated for IE and Chrome after we added X-Content-Type-Options: nosniff header).