Setting the right type of headers for Tomcat 4
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Mehjabin_Kapasi
Posted On:   Thursday, March 21, 2002 08:48 AM

Hello, I have a web application that displays a word document in the web browser. There is also a download link for the user to download the document on their machine. When this application was running with tomcat 3.2.1, when the user clicked on the link the browser dialog would appear asking the user to either open or save the document. When i try to run this application with Tomcat 4.0.3, when i click on the download link i get garbage on the page which looks like this... Can someone help me with this? ÐÏࡱá>þÿ‹þÿÿÿ‰ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ    More>>

Hello,
I have a web application that displays a word document in the web browser. There is also a download link for the user to download the document on their machine. When this application was running with tomcat 3.2.1, when the user clicked on the link the browser dialog would appear asking the user to either open or save the document.
When i try to run this application with Tomcat 4.0.3, when i click on the download link i get garbage on the page
which looks like this... Can someone help me with this?
ÐÏࡱá>þÿ‹þÿÿÿ‰ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿì¥ÁW
ø ¿ Â" bjbjªyªy ŠdÈ È õ Ìÿÿ ÿÿ ÿÿ l       4Ž ®!®!®!h "DZ"´Ž
1v(#Æà$¦†%†%†%†%¢ (0,T3˜°u²u²u²u²u²u²u$Yx yzŒÖu  ì4†%†%ì4ì4Öun: Â
†%†%ëu n:n:n:ì4 †% †%°un:ì4°un:2 n: A^ ¨jà   |q†% # €¿m ÚBÁŽ
®!7&ˆph|q4 v01vðpŒ {,9B {|qn:ö XN @    ٠SUBJECT * MERGEFORMAT
ClassicsCD Web Shop title * Mergeformat Vision Version 2.1 Revision
History Date Revision Description Author 20/Oct/2001 1.0 Initial Version P
Murphy 10/Nov/2001 2.0 Updated based on Requirements Workshop P
Murphy 15/Nov/2001 2.1 Editorial Revisions S. Chandler
[contractor]
Table of Contents TOC o "1-3" 1. Introduction PAGEREF
_Toc523131581 h 1 1.1 Purpose of the Vision Requirements Document (VRD)
PAGEREF _Toc523131582 h 1 1.2 Product Overview PAGEREF _Toc523131583
h 1 2. User Description PAGEREF _Toc523131584 h 1 2.1 User/Market
Demographics PAGEREF _Toc523131585 h 1 2.2 User Profiles PAGEREF
_Toc523131586 h 1 2.3 User Environment PAGEREF _Toc523131587 h 1
2.4 Key User Needs PAGEREF _Toc523131588 h 2 2.5 Alternatives and
Competition .......

   <<Less

Re: Setting the right type of headers for Tomcat 4

Posted By:   michael_dean  
Posted On:   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





doc
application/msword



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. :)

About | Sitemap | Contact