• Post Reply Bookmark Topic Watch Topic
  • New Topic

Error 500: Cannot forward. Response already committed  RSS feed

 
Isuru Jay
Greenhorn
Posts: 9
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I'm working with java 1.5 and jasperreports-2.0.1. While generating a report I'm getting some errors but output report is generated without an issue for all html,csv and excel format. but bottom of the report error message is displayed. " Error 500: Cannot forward. Response already committed ".
This happens in websphere only. I'm using tomcat 5.5 too. In tomcat no errors will be displayed nor on the report.

This is the code I'm using for generating csv report.


public void genReportCSVFormat(ServletContext application,String filename,
Map customParams, HttpServletResponse response,String outputFileName){

Connection con = null;
try {
con = getConnection();
File reportFile = new File(application
.getRealPath(IReportConstant.JASPER_COMPILE_PATH + filename));

JasperReport jasperReport = (JasperReport) JRLoader
.loadObject(reportFile.getPath());


JasperPrint jasperPrint = JasperFillManager.fillReport(
jasperReport, customParams, con);

JRCsvExporter csvExporter = new JRCsvExporter();
csvExporter.setParameter(JRCsvExporterParameter.FIELD_DELIMITER,
",");
csvExporter.setParameter(JRCsvExporterParameter.RECORD_DELIMITER,
"\n");
csvExporter.setParameter(JRCsvExporterParameter.JASPER_PRINT,
jasperPrint);
csvExporter.setParameter(JRCsvExporterParameter.OUTPUT_STREAM,
response.getOutputStream());

response.setContentType("application/csv");

response.setHeader("Content-Disposition", "inline; filename="+outputFileName);


csvExporter.exportReport();

} catch (Exception e) {
e.printStackTrace();
}
}

The error I'm getting in websphere log as follow.

[4/22/12 15:27:33:973 AST] 00000034 ServletWrappe E SRVE0068E: Uncaught exception thrown in one of the service methods of the servlet: action. Exception thrown : java.lang.IllegalStateException: Cannot forward. Response already committed.
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:148)
at org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1085)
at org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:398)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:241)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:763)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:989)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:930)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:145)
at com.affno.mob.common.filter.SessionCheckingFilter.doFilter(SessionCheckingFilter.java:151)
at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:190)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:130)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain._doFilter(WebAppFilterChain.java:87)
at com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:761)
at com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:673)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:498)
at com.ibm.ws.wswebcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:464)
at com.ibm.ws.webcontainer.servlet.CacheServletWrapper.handleRequest(CacheServletWrapper.java:90)
at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:744)
at com.ibm.ws.wswebcontainer.WebContainer.handleRequest(WebContainer.java:1433)
at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:96)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:465)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java:394)
at com.ibm.ws.http.channel.inbound.impl.HttpICLReadCallback.complete(HttpICLReadCallback.java:102)
at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:152)
at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:213)
at com.ibm.io.async.AbstractAsyncFuture.fireCompletionActions(AbstractAsyncFuture.java:195)
at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:136)
at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:194)
at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:741)
at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:863)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1469)



So please help me to solve this. Thanks...
 
Isuru Jay
Greenhorn
Posts: 9
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can anybody help me???
 
Rob Spoor
Sheriff
Posts: 21052
85
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch!

The error message says it all. You try to forward to some other servlet or JSP page (but not from this code), while you've already written some data to the response's output stream or writer.

And you should know that PatienceIsAVirtue (<= click).
 
Isuru Jay
Greenhorn
Posts: 9
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Done and thanks Rob. Here I used struts for my front end. above method is called from the action class and that action class forward to a jsp file. What i did was just return null from the action class. Now it is ok. Thanks again
 
Rob Spoor
Sheriff
Posts: 21052
85
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're welcome.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!