contentType="application/vnd.ms-excel" Not Working
I have a page with a grid on it that I want to export to excel. This has been working for quite some time (years) but the other day instead of opening in excel it has been opening in a browser window. Since the code is the same I am thinking it is a problem with a java or tomcat update. Does anyone know if there is a new code instead of: <%--@page contentType="application/vnd.ms-excel"--%>"?
Here is the bulk of my code. Thanks in advance.
-Jordan
<%--@page contentType="application/vnd.ms-excel"--%>
<jsp:useBean id="map" class="com.esri.aims.mtier.model.map.Map" scope="page" />
<%@ page import="java.net.URLEncoder" %>
<%@ page import="javax.xml.parsers.DocumentBuilderFactory" %>
<%@ page import="javax.xml.parsers.DocumentBuilder" %>
<%@ page import="com.esri.aims.mtier.model.map.layer.query. *" %>
<%@ page import="org.w3c.dom.*" %>
<%!
private String formatURLString(String inputURL) {
if (inputURL.indexOf("htt*p://")>-1 || inputURL.indexOf("htt*ps://")>-1 || inputURL.indexOf("ftp://")>-1) {
return inputURL;
} else if (inputURL.indexOf("ww*w.")==0) {
return "htt*p://"+inputURL;
} else {
return "htt*p://"+inputURL;
}
}
String cleanHeader(String h) {
if (h.indexOf('.')>-1) {
h=h.substring(h.lastIndexOf('.')+1,h.length());
}
return h;
}
%>
<%@ include file="setupinc.jsp" %>
<%
if (session.getAttribute("ResultsExport") !=null && request.getParameter("doExport")!=null &&
request.getParameter("doExport").equals("true")) {
try {
recordResult rr = (recordResult)session.getAttribute("ResultsExport" );
if (rr.features!=null && rr.metadata!=null &&
rr.features.length>0 && rr.metadata.fieldNames.length>0) {
out.print("<table border=\"1\" cellspacing=\"0\" class=\"r\"><tr>");
int i, j; // iterators
String str;
for (i=0; i<rr.metadata.fieldNames.length; i++) {
str=cleanHeader(rr.metadata.fieldNames[i]);
if (!str.equalsIgnoreCase("#shape#")) {
out.print("<th>"+str+"</th>");
}
}
out.print("</tr>");
for (i=0; i<rr.features.length; i++) {
out.println("<tr>");
for (j=0; j<rr.features[i].values.length; j++) {
if (!rr.metadata.fieldNames[j].equalsIgnoreCase("#shape#")) {
out.println("<td>"+rr.features[i].values[j]+"</td>");
}
}
out.println("</tr>");
}
out.print("</table>");
} else {
out.print("<table border=\"1\" cellspacing=\"0\" class=\"r\">");
out.print("<tr><th>Null Issue</th></tr></table>");
}
} catch (Exception e) {
out.print("Error: "+e);
}
}
%>