aspose file tools*
The moose likes Servlets and the fly likes The IE and Netscape conflict again!! :-) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "The IE and Netscape conflict again!! :-)" Watch "The IE and Netscape conflict again!! :-)" New topic
Author

The IE and Netscape conflict again!! :-)

maha anna
Ranch Hand

Joined: Jan 31, 2000
Posts: 1467
Hi,
I have a requirement of showing a dynamically generated data from database in Excel Format ,NOT as html page. It was back of my mind how I am going to do like that. Recently I bought the 'Core Servlet Programming' servlet book by Marty Hall. In that I got a solution like when we set the response contentType header as 'application/***the_registerd_appln_type' when the response is sent to the browser , the browser will open with the corresponding application.
Well, I was happy I got a solution. The MS-Excel appn. will be in all my users m/c. But when I tested with Netscape and IE, ONLY netscape asks us to open with Excel s/w while IE just displays as a html file. I can't force the users to use Netscape all the times. This is the problem. Is there any SPECIAL setup we need to do for IE to open with Excel appln? I did check but couldn't see any. Please take a look at this link in my appln which I tested with online. Try to goto this link through Netscape and IE.
http://www.webappcabaret.com/maha/Login/misExcel1.jsp
[Marty Hall DOES warn about this conflict when he talked about when setting the response content type as "text/plain", IE does not show as plain, instead it shows as html file though. ]
Can anybody give a solution to this? Basically what I need is the user should be able to SAVE the result from the database as an Excel file in his/her machine. The .jsp file's content is like below.
Thanks a lot.
regds
maha anna


[This message has been edited by maha anna (edited October 11, 2000).]
Jeroen Wenting
Ranch Hand

Joined: Oct 12, 2000
Posts: 5093
Try using application/msexcel instead as the mime-type.
This is in line with the mime-type for MS Word. If it works, it should open Excel with the file inside the browser window in IE, what it does in Netscape is anybody's guess


42
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12769
    
    5
As I recall, you have settings in the browser as to which data types it will recognize. Maybe your MSIE just doesn't have the right settings.
Bill
maha anna
Ranch Hand

Joined: Jan 31, 2000
Posts: 1467
Thanks Jeroen Wenting and Bill. Both Netscape and IE are opening with Excel now. I didn't set anything new. Yet to explore the settings in IE and Jeroen's tip.
regds
maha anna
ajay pai
Greenhorn

Joined: Jun 21, 2001
Posts: 1
Can I get the code for this file misExcel1.jsp --
Vikas Aggarwal
Ranch Hand

Joined: Jun 22, 2001
Posts: 140
Hi!,
I have tried a lot of things to do that. But there are many options and you can try all of them.
here they are:
in the JSP at the top ...
<%@ page contentType="application/vnd.ms-excel" %>
<% response.setHeader("Content-Type","application/vnd.ms-excel");%>
<% response.setContentType("application/vnd.ms-excel");%>
In the <head></head> tag of the html use a meta tag..
<meta http-equiv="Content-Type" content="application/x-msexcel; charset=ISO-8859-1">

I have tried them and it works beautifully on both browsers.
Originally posted by maha anna:
[B]Hi,
I have a requirement of showing a dynamically generated data from database in Excel Format ,NOT as html page. It was back of my mind how I am going to do like that. Recently I bought the 'Core Servlet Programming' servlet book by Marty Hall. In that I got a solution like when we set the response contentType header as 'application/***the_registerd_appln_type' when the response is sent to the browser , the browser will open with the corresponding application.
Well, I was happy I got a solution. The MS-Excel appn. will be in all my users m/c. But when I tested with Netscape and IE, ONLY netscape asks us to open with Excel s/w while IE just displays as a html file. I can't force the users to use Netscape all the times. This is the problem. Is there any SPECIAL setup we need to do for IE to open with Excel appln? I did check but couldn't see any. Please take a look at this link in my appln which I tested with online. Try to goto this link through Netscape and IE.
http://www.webappcabaret.com/maha/Login/misExcel1.jsp
[Marty Hall DOES warn about this conflict when he talked about when setting the response content type as "text/plain", IE does not show as plain, instead it shows as html file though. ]
Can anybody give a solution to this? Basically what I need is the user should be able to SAVE the result from the database as an Excel file in his/her machine. The .jsp file's content is like below.
Thanks a lot.
regds
maha anna


[This message has been edited by maha anna (edited October 11, 2000).][/B]


------------------
Vikas Aggarwal
Technology Associate
Shakun Global Networks


Vikas Aggarwal

Founder @
Leads and Deals Limited

www.LeadsAndDeals.com
Praveen Kumar Jha
Greenhorn

Joined: Jul 27, 2002
Posts: 10
Maha,
can I save the excel report from repsonse object on server side?


Praveen Kumar<br />Sun Certified Programmer for Java 2 Platform
Byron Estes
Ranch Hand

Joined: Feb 21, 2002
Posts: 313
The intermitency of the problem could have been related to cacheing since you didn't do anything, but the problem went away. This leads me to believe you had an old "cached version" and it didn't get reloaded until later.
Regards,


Byron Estes<br />Sun Certified Enterprise Architect<br />Senior Consulant<br />Blackwell Consulting Services<br />Chicago, IL<br /><a href="http://www.bcsinc.com" target="_blank" rel="nofollow">www.bcsinc.com</a>
Bharat Reddy
Greenhorn

Joined: Oct 28, 2002
Posts: 1
Hi Guys,
I could output data to an excel file. But, the requirement i have is, i need to output 2 different sets of data to 2 worksheets of the same excel file. How do i achieve this? Currently i am using the following code:
response.setContentType("application/vnd.ms-excel");
response.setHeader("Content-disposition","attachment;filename=_search_results.xls");
Bharat
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: The IE and Netscape conflict again!! :-)