Viewing Excel files using JSP

B

BenJose

Iam using a simple webpage to view/download excel files. But for some
reason I use the <a href> tag to point to the excel file and it shows
up garbled. I tried altering the content type and also did some tweaks
but nothing works... Any pointers in this regards ??

Iam using a Apache Tomcat server.

This is the script itself:
<html>

<head>

<meta http-equiv="Content-Language"
content="application/vnd.ms-excel">
<meta http-equiv="Content-Type" content="application/vnd.ms-excel;
charset=windows-1252">

<title>Maine Educational Assessment</title>
<style type="text/css">
<!--
..style1 {font-size: 10px}
-->
</style>

<!-- End of: /portal/sliverheader/sliverhead.html -->

</head>
<body marginheight="0" marginwidth="0">

<a href="tst.xls">Excel Tst</a>

</body>

</html>

-Ben
 
T

Tony Morris

BenJose said:
Iam using a simple webpage to view/download excel files. But for some
reason I use the <a href> tag to point to the excel file and it shows
up garbled. I tried altering the content type and also did some tweaks
but nothing works... Any pointers in this regards ??

Iam using a Apache Tomcat server.

This is the script itself:
<html>

<head>

<meta http-equiv="Content-Language"
content="application/vnd.ms-excel">
<meta http-equiv="Content-Type" content="application/vnd.ms-excel;
charset=windows-1252">

<title>Maine Educational Assessment</title>
<style type="text/css">
<!--
.style1 {font-size: 10px}
-->
</style>

<!-- End of: /portal/sliverheader/sliverhead.html -->

</head>
<body marginheight="0" marginwidth="0">

<a href="tst.xls">Excel Tst</a>

</body>

</html>

-Ben

Which has what to do with Java?
 
S

shakah

You probably have to add Excel to Tomcat's MIME types in order for it
to send the correct response header.

I think you just have to add the following to the webapp's web.xml (as
a child of the web-app tag):

<mime-mapping>
<extension>xls</extension>
<mime-type>application/msexcel</mime-type>
</mime-mapping>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,570
Members
45,045
Latest member
DRCM

Latest Threads

Top