Open Excel file in Browser for expoting data from server

Discussions

EJB design: Open Excel file in Browser for expoting data from server

  1. Hi I have a class where the following fuction is written: ================================================ public String getMyCSV() { HttpServletResponse Response; try { Response = (HttpServletResponse)getExternalContext().getResponse(); ServletOutputStream outs = Response.getOutputStream(); Response.setContentType("application/vnd.ms-excel"); Response.setHeader("Content-Disposition", "attachment; filename=\"log.csv\""); Response.setHeader("Cache-Control", "public"); Response.setHeader("pragma", ""); try { outs.print(getCSVOutput()); } catch (IOException ioe) { debugLog("Error exporting file", ioe); } ---------------------------------------> I have another file which is accessed in the browser to access this function: <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %> <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %> <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %> -------> Observed: when this JSP file is accessed i get the following error: Exception occured while loading the page: Servlet response already use stream, Writer not possible. I was suspecting the following: the mime-mapping was not available in the web.xml so i added the following: xls application/vnd.ms-excel I would be glad if someone could give me some advice on this. Regards Baig
  2. This msg is posted by mistake in EJB forum. I have reposted the same one in JSP Web tier framework. Thanks Baig