I have a mhtml file with embedded images. It is stored in a folder in local file system. I have a servlet in my web app that reads this .mht file using plain old file IO. This servlet sets the Content-Type to
and then writes what it read from .mht file to the response. Problem is when client receives the response, it cannot see the image, appears as broken link. What is the correct Content-Type to be set for .mht files or there something else needs to be done?
_ __ _ __ _ __ _<br />SCJP 1.4 (95%) | SCWCD 1.4 (79%)<br />Artificial intelligence is no match for natural stupidity.
If you save the file (as streamed by the servlet) to your local hard drive, can you still open it and view it with your browser? If not, maybe the file is being corrupted in the streaming process.
Also, are you setting the Content-Disposition header? MSIE often disregards the Content-Type header and tries to figure out what the file type is by its file extension. Maybe setting a file name with an .mhtml ext will be enough for the browser to figure out what it is.
Joined: Nov 05, 2003
Does not look like the file is getting corrupted. If I do view source, only thing looks like is image data missing.
does not make any difference.
If I try the same thing in Firefox, it tries to download the file. But, if I set it to open automatically without asking, then Firefox saves the file in C:\temp and then opens it from C:\temp in a new tab using IE plug-in.
Interesting part is when I view source of this page (from IE tab), it does not have image data either, but image shows up. Looking at the properties of the image it indicates it's location is
Even if it works on Firefox, it does not resolve my problem as application suppose to be IE compatible. Did it out of curiosity.
Joined: Nov 05, 2003
I found what was the problem. If the .mhtml file has spaces in the name, then images do not show up. Otherwise it works! Only thing I need to set is content-type to message/rfc822.
Can I say stupid MS bug? (mhtml being MS invented format)
I tried reading a .mht file from a servlet and writing it to the response using BufferedInputStream . I have set the content-type to "message/rfc822".
But when I execute the servlet a blank page is displayed in the browser. Do I need to set anything else.
Kindly guide me as you were able to read and send the response to the client.