I have a servlet that produce an excel file using POI HSSF. The info. printed on that file is obtained through a database. The problem is that when I want to print a lot of rows on excel it throws an exception, as follows: SEVERE: StandardWrapperValve[REPCBRR090SRV]: Servlet.service() for servlet REPCB RR090SRV threw exception java.lang.IllegalStateException: Cannot forward after response has been committe d at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationD ispatcher.java:375) at org.apache.catalina.core.ApplicationDispatcher.access$000(Application Dispatcher.java:123) at org.apache.catalina.core.ApplicationDispatcher$PrivilegedForward.run( ApplicationDispatcher.java:138) at java.security.AccessController.doPrivileged(Native Method) at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDis patcher.java:355) at code.com.nextel.servlet.REPCBRR090SRV.doTask(REPCBRR090SRV.java:155) at code.com.nextel.servlet.NextelSrv.doGet(NextelSrv.java:77) at javax.servlet.http.HttpServlet.service(HttpServlet.java:740) at code.com.nextel.servlet.NextelSrv.service(NextelSrv.java:44) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at org.apache.catalina.core.StandardWrapperValve.invokeServletService(St andardWrapperValve.java:720) at org.apache.catalina.core.StandardWrapperValve.access$000(StandardWrap perValve.java:118) at org.apache.catalina.core.StandardWrapperValve$1.run(StandardWrapperVa lve.java:278) at java.security.AccessController.doPrivileged(Native Method) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV alve.java:274) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav a:505) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextV alve.java:212) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav a:505) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j ava:203) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav a:505) at com.iplanet.ias.web.connector.nsapi.NSAPIProcessor.process(NSAPIProce ssor.java:157) at com.iplanet.ias.web.WebContainer.service(WebContainer.java:598) I have done several tests: 1. If I obtain 10K (10000 rows) from database, it produce an output on excel of around 25K rows. the difference is because all the titles and related stuff with the output (like titles, cuts, and so on just for printing purposes) 2. If I obtain 15K (15000 rows) from database, it produce an output on excel of around 30K rows. 3. Then if I obtain 20K (20000 rows) from database, it produce an output on excel of around ????, here it throws the EXCEPTION!!! I have increased my buffer size on the servlet with: response.setBufferSize(32000); when it had around 8900 (retrieved with getBufferSize()), and nothing. Hope somebody can help me! Thanks. I appreciate you can reply me to: gab_s@hotmail.com
As far as I can tell this is a logic error with your servlet not a problem with POI. You shouldn't be forwarding after serving data to the user. Make the decision to forward before you start spitting out any data.