tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Schultz <>
Subject Re: Tomcat issue : open a office 2007 document
Date Sat, 16 Jan 2010 16:22:17 GMT
Hash: SHA1

To whom it may concern,

On 1/15/2010 3:55 PM, soulSnatched wrote:
> I am trying to open a office 2007 document a .xlsx file 

Technically speaking, you are trying to send an Office 2007 document to
a client, and that client is trying to open the file.

> I am using  tomcat 6.18 on Windows XP platform

Let's call that 6.0.18 just to be precise.

> Currently i am using 
> in my jsp:
> response.setContentType("application/"); 
> and the mime mapping in tomcat/conf/web.xml is defined as : 
> <mime-mapping>
>         <extension>xls</extension>
>         <mime-type>application/</mime-type>
>     </mime-mapping>

The MIME mapping is not relevant, here, because:

1. Your URL ends in .jsp and won't match .xls
2. You are running your own servlet (JSP) which does not
   appear to use the MIME mapping.

> It opens fine in excel 2003 but with an annoying pop up...

What does the pop-up say?

> but i need it to open it in excel 2007

I'm not sure you can have Excel 2003 and Excel 2007 installed at the
same time. Isn't it the client's job to determine which program handles
files of certain types?

> so i made the following changes but its not working 
> jsp:
> response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");

Is that the right MIME type for MS's new "open" XML format?

> mime mapping in web.xml
> <mime-mapping> 
> <extension>xlsx</extension> 
> <mime-type>application/vnd.openxmlformats-officedocument.spreadsheetml.sheet</mime-type>

> </mime-mapping> 

Again, the MIME mapping is not relevant since you're setting the MIME
type explicitly in the response.

> it opens but with an error saying 
> "Excel cannot open file 'xxx' because the file format or file extention is
> not valid. verify that the file has not been corrupted or that the file
> extension matches the format of the file" 

Is it possible that you aren't sending the file correctly? Could you
post more of your JSP file?

Have you snooped the HTTP conversation to make sure that the
Content-Type is being properly sent and that the response contains the
data you expected to send?

Using JSPs to serve files is inherently dangerous because it's tough to
remove all the whitespace that JSP files dump into the output stream.
You are likely corrupting the file as you send it.

- -chris
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Mozilla -


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message