| Author |
java.lang.IllegalStateException: strict servlet API: cannot call getWriter() after getOutputStream
|
Akash Wairagade
Greenhorn
Joined: Jul 11, 2008
Posts: 1
|
|
hi ,
i am getting below error while trying to implement export to excel functionality in Icefaces
HttpServletResponse response =(HttpServletResponse) FacesContext.getCurrentInstance().getExternalContext().getResponse();;
response.setContentType("application/vnd.ms-excel");
response.setHeader("Content-Disposition", "attachment; filename=name.xls");
HSSFWorkbook workbook = new HSSFWorkbook();
HSSFSheet sheet = workbook.createSheet("Sheet1");
// declare a row object reference
HSSFRow row = null;
// declare a cell object reference
HSSFCell cell = null;
row = sheet.createRow(1);
cell = row.createCell((short) 0);
cell.setCellValue(100);
workbook.write(response.getOutputStream());
response.getOutputStream().flush();
return null;
org.icefaces.impl.application.ExtendedExceptionHandler handle
WARNING: queued exception
java.lang.IllegalStateException: strict servlet API: cannot call getWriter() after getOutputStream()
thanks in advance
Akash
|
 |
Tim Holloway
Saloon Keeper
Joined: Jun 25, 2001
Posts: 14487
|
|
Welcome to the JavaRanch, Akash!
JSF is designed to process and display HTML. Excel is a proprietary non-HTML format, so JSF is not a good rendering engine for it. Instead, put the Excel output code in a standard (non-JSF) servlet. You can then put the servlet's URL on a JSF page using an h:outputLink or similar connector.
|
Customer surveys are for companies who didn't pay proper attention to begin with.
|
 |
 |
|
|
subject: java.lang.IllegalStateException: strict servlet API: cannot call getWriter() after getOutputStream
|
|
|