• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

java.lang.IllegalStateException: strict servlet API: cannot call getWriter() after getOutputStream

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Saloon Keeper
Posts: 27808
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic