Thursday, March 21, 2002 01:29 PM
If you are generating the word document dynamically, you will need to set the correct MIME content type with the setContentType(String) method of your ServletResponse. You will probably want to use response.setContentType("application/msword");
If, on the other hand, it's a static document, you can specify the MIME type based on the file's extension. Do this by adding a "mime-mapping" tag to your web.xml file as shown
Most likely, this is what you're trying to do, and it worked in Tomcat 3.x because of the default mappings. However, if your application relies on it, you should specify it in your deployment descriptor regardless of the defaults.
Note that the default web.xml in Tomcat 4.0.3--I don't have copies of older ones--includes this mapping, so it may be your web server that's failing to make the mapping. If you're using Apache or another web server with Tomcat, make sure the appropriate mime mappings are specified for it, also.
Finally, I'm sure you've considered this, but just in case, I'll mention it. You might want to take into account the fact that, contrary to popular belief, not everyone has MS Word. Perhaps you could make the document available in other formats, i.e. PDF, PostScript, HTML, etc. Just make sure you include the appropriate mime mappings. :)