0
votes

Exception Trace:

""java.lang.IllegalStateException: Cannot forward after response has been committed at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:328) at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:318) at com.zoho.campaign.client.filters.CampaignDomainFilter.doFilter(CampaignDomainFilter.java:140) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207) at com.zoho.campaign.client.filters.CampaignDefaultFilter.doFilter(CampaignDefaultFilter.java:165) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207) at com.adventnet.iam.security.SecurityFilter.doFilter(SecurityFilter.java:217) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207) at com.adventnet.zoho.crmplus.agent.filter.CRMPlusFilter.doFilter(CRMPlusFilter.java:55) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207) at com.zoho.logs.logclient.filter.AccessLogFilter.doFilter(AccessLogFilter.java:61) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207) at com.zoho.instrument.InstrumentFilter.doFilter(InstrumentFilter.java:37) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502) at org.apache.catalina.valves.rewrite.RewriteValve.invoke(RewriteValve.java:480) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79) at org.apache.catalina.authenticator.SingleSignOn.invoke(SingleSignOn.java:240) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:528) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1099) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:672) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1520) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1476) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Thread.java:745)

when try to Forward the RequestDispatcher iam getting this Exception

What is the Reason of this Problem Occurs?

Code:

public void doFilter(ServletRequest req,ServleResponse res,FilterChain filterchain)thorws IOException,Exception
{
String downloaurl="expired";
boolean is_allow_download=false;
HttpServletRequest request=(HttpServletRequest)req;
HttpServletResponse response=(HttpServletResponse)res;
RequestDispatcher rd=null;
if(downloadurl.equals("expired"))
    {
    request.setAttribute("isexpire", "expire");
  }
  else if(downloadurl.equals("no_data"))
     {
       request.setAttribute("isdataAval", false);
  }
     if(url1.contains("export.do") && !downloadurl.equals("no_data") && is_allow_download )
       {
         rdc = request.getRequestDispatcher("users/export.do");
         rdc.forward(request, response);
       }
      rdc = request.getRequestDispatcher("users/closed.do"); 
        rdc.forward(request, response);

}
1
Paste your code here. It is very common mistake. It is saying that control has already returned, so no use of forward().Umesh Kumar Sharma

1 Answers

0
votes

On the assumption of your stack trace, your RS has been committed before you are trying to call forward() method. Your application has returned RS earlier.

p.s. Please add some code snippets for more context.