getting error java.lang.IllegalStateException: getOutputStream() has already been called for this response
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Abhilash_Boinapally
Posted On:   Thursday, June 29, 2006 01:15 AM

when i am executing below program i am getting error <%@page import="java.io.*"%> <%@page import="java.sql.*"%> <%@page import="org.apache.poi.hssf.usermodel.*"%> <%@page import="org.apache.poi.hssf.dev.*"%> <%@page import="org.apache.poi.hssf.util.*"%> slno name 1 Abhilash 2 Sarvana <% response.setContentType("application/vnd.ms-excel"); response.setHeader("Content-disposition","attachment;fi   More>>
			
when i am executing below program i am getting error

<%@page import="java.io.*"%>
<%@page import="java.sql.*"%>
<%@page import="org.apache.poi.hssf.usermodel.*"%>
<%@page import="org.apache.poi.hssf.dev.*"%>
<%@page import="org.apache.poi.hssf.util.*"%>
















slno name
1 Abhilash
2 Sarvana

<%
response.setContentType("application/vnd.ms-excel");
response.setHeader("Content-disposition","attachment;filename=Web_Transact_Report.xls");
System.out.println("Going to create Excel file");
int rownum = 0 ;
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet = wb.createSheet("Transaction Report");
System.out.println("Going to create rows");
HSSFRow row = sheet.createRow((short)rownum);
rownum++;
HSSFCell cel ;
cel = row.createCell((short)0);
cel.setCellValue("slno");
//cel.setCellStyle(headerStyle);
cel = row.createCell((short)1 );
cel.setCellValue("Name");
//cel.setCellStyle(headerStyle);
System.out.println("writing data to response");
wb.write(response.getOutputStream());
%>


the program is about extracting data from html and storing in excel sheet
   <<Less

Re: getting error java.lang.IllegalStateException: getOutputStream() has already been called for this response

Posted By:   Bhanu_P  
Posted On:   Tuesday, July 11, 2006 03:07 AM

Hi,U r getting error because, u have already got the JSPWriter and commited response. after commiting response u cann't set ContentType...
Actually the Table will printed by the help of "out" implicit object which is of type JSPWriter..
u shoud setContent be4 printing the Table..

Re: getting error java.lang.IllegalStateException: getOutputStream() has already been called for this response

Posted By:   Christopher_Koenigsberg  
Posted On:   Saturday, July 8, 2006 02:06 PM

I think you already implicitly "got" the OutputStream, back when you called "response.setContentType".
About | Sitemap | Contact