What Happens when you mix Internet Explorer, Microsoft Office, and Coldfusion 9? A whole lotta yuck.

So things started off bad… I’m fighting a gnarly cold and keep coughing up some gnarlyness making me grumpy and discontent. Then this:

I’ve been working on a recent migration of some (shudders as I say this) Coldfusion 8 applications to Coldfusion 9 to support  Office 2007 document types. This is in no way shape or form “glamorous” work.  First off, I hate being this high up in the stack – way too many layers of abstraction here, and way too many places for things to go wrong in some black box that nobody can see inside (small rant).

So – I make a few changes to the code and use the shiny new <cfspreadsheet> tag CF9 provides, and ship it off to QA for testing in it’s spify new Coldfusion 9 home in QA.

All goes well in Firefox and all seems calm on the homefront… Then IE rolls into town.

Within the application is a directory with a few .xls, .doc, and .pdf files. The application has a few links so the user can grab these files from the server. Firefox handled that no problem. It saw the extension, and passed it along to MS Office.

Internet Explorer, Well… it decided that it thought it was man enough to display the file on its own. It couldn’t. Instead it just barfed up the file in the browser leaving only chunks somewhat readable.

After a little digging and some HTTP Header recording user the Live HTTP FF plugin, it was apparent that the MIME type wasn’t defined.  There wasn’t any Content-Type coming back when the URL to the Office files were hit!

This is no bueno. Firefox can man up and has a stronger stomach. IE? well… No MIME type means no worky.

So here’s the problem, I have an Office Document ( .xls , .doc , etc…) sitting in a directory of a Coldfusion 9 application being served up by a Coldfusion 9 Server (yuck!) which is Java based and runs in a Java Container (in my case Weblogic) running on top of a JVM on top of a well… no need to go this far down (for this anyway).

So who or what do I tell to whom so that someone knows what MIME type they’re getting if they ask for above mentioned file???

Here’s the solution – tell Coldfusion’s web.xml file.

As it turns out, the MIME type info isn’t specified in the web.xml file out of the box. Go ahead and edit web.xml and add the following lines:

<mime-mapping>
     <extension>xls</extension>
     <mime-type>application/vnd.ms-excel</mime-type>
</mime-mapping>
<mime-mapping>
    <extension>doc</extension>
    <mime-type>application/vnd.ms-word</mime-type>
</mime-mapping>

Of course, if there are other MIME types that need defining you’d better go ahead and add those too.

Go ahead and restart the CF server and presto-chango! Things should be AOK.
Good Luck!

1 Comment

Filed under Java, Rants

One response to “What Happens when you mix Internet Explorer, Microsoft Office, and Coldfusion 9? A whole lotta yuck.

  1. That’s why in case you really want to enjoy and unwind next
    why not doit with your full household.

Leave a comment