Hi Dragan,

 

Although I don’t exactly remember what I said in the thread you mentioned,
here are few questions for you to answer

*       As the file opens correctly when opened directly or through other
tomcat server, the problem is not likely in the file. 
Do you save these files on server hard disk first or stream directly from
server?
*       The problem could be in the headers being sent by server to browser
When you open the attached excel file through the Linux SuSE + tomcat, does
the garbage shows up in MS Excel or directly in the browser window?

 

I tried your file through following combinations

 

Windows XP + Tomcat 4.1 

Internet Explorer: Garbage in IE6 Window (excel does not launch)

Firefox 2 Opens correctly

 

Windows XP + Tomcat 5.5 

Internet Explorer: Garbage in IE6 Window (excel does not launch)

Firefox 2 Opens correctly

 

I inspected HTTP headers returned by tomcat and found that tomcat does not
return any MIME type header by default. I am using Tomcat directly (i-e not
behind Apache Webserver or IIS). My assessment after this test is that the
bug lies in Internet Explorer (as usual :-). It appears to me that IE fails
to detect the file type correctly in some cases in absence of proper MIME
headers. 

 

You can try following approaches:

1. Add a mime-mapping in tomcat/conf/web.xml. I tried this and excel file
started opening correctly in IE6 (Restart tomcat and delete temporary
internet files from IE). 

    <mime-mapping>

        <extension>xls</extension>

        <mime-type>application/octet-stream</mime-type>

    </mime-mapping>

2. Instead of letting Tomcat serve the file create a custom servlet and set
HTTP headers manually like 
        response.setContentType("application/octet-stream");

        response.setHeader("Content-Disposition", "attachment;
filename=report.xls"  );

 

Wassalam

 

Tahir Akhtar

 

  _____  

From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
Sent: Friday, March 16, 2007 3:02 AM
To: [EMAIL PROTECTED]
Subject: Re: Excel Export

 


Hello, Tahir, 

I've seen your name in an Apache/Tomcat thread regarding a problem 
which I also have from time to time. Some very simple Excel sheets 
show as garbage through a Tomcat 5.0.28 and 4.1.27  running under 
Linux SuSE 10.1 but the same file display just fine when opened 
directly or through a Tomcat 4.1 running under Windows XP. 

In one case I was able to restore proper Excel view by saving the 
same file from Excel 2002 but in other cases that didn't help either. 

I am enclosing one such file in the hope that you might find out 
what is wrong. Is it OK with you? 





I've even saved the file under a different name but it behaves just 
like this one - it displays as garbage in the IE6 browser. The new 
file is slightly bigger (exactly 512 bytes) than the original file here. 

Do you see anything wrong with this file? 
Why does it not display properly? 

I have thousands of such Excel sheets which do display OK, 
but from time to time there is such a file which just won't 
display properly through a Linux Tomcat server but displays 
perfectly thgough a Windows XP Tomcat. 

It drives me nuts. 


Dragan Krnic
DB Fernverkehr AG
P.TVN5 
Stephensonstraße 1/I-01/27, 60326 Frankfurt
Tel. +49 (0)69/265-59612, Fax (0)69/265-7550
________________________________________________________________
Internetauftritt der Deutschen Bahn AG >> http://www.db.de

Reply via email to