Java.lang.IllegalStateException: Cannot forward. Response already committed

i have deployed my application on Websphere application server 5.0. most of the time my jsp page works properly with any exception, but somtime it give me expeception and display page uncompletely rendered.
Follwoing exception occure on particual page with particular record and same page works correctly with other reocrds....
java.lang.IllegalStateException: Cannot forward. Response already committed. (Servlet 2.3, SRV 8.4)
     at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:160)
     at com.mcb.cpms.presentation.controllers.CPMSController.dispatchRequest(CPMSController.java:918)
     at com.mcb.cpms.presentation.controllers.CPMSController.doGet(CPMSController.java:1278)
     at com.mcb.cpms.presentation.controllers.CPMSController.doPost(CPMSController.java:1308)
     at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
     at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
     at com.ibm.ws.webcontainer.servlet.StrictServletInstance.doService(StrictServletInstance.java:110)
     at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet._service(StrictLifecycleServlet.java:174)
     at com.ibm.ws.webcontainer.servlet.IdleServletState.service(StrictLifecycleServlet.java:313)
     at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet.service(StrictLifecycleServlet.java:116)
     at com.ibm.ws.webcontainer.servlet.ServletInstance.service(ServletInstance.java:283)
     at com.ibm.ws.webcontainer.servlet.ValidServletReferenceState.dispatch(ValidServletReferenceState.java:42)
     at com.ibm.ws.webcontainer.servlet.ServletInstanceReference.dispatch(ServletInstanceReference.java:40)
     at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.handleWebAppDispatch(WebAppRequestDispatcher.java:948)
     at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.dispatch(WebAppRequestDispatcher.java:530)
     at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:176)
     at com.ibm.ws.webcontainer.srt.WebAppInvoker.doForward(WebAppInvoker.java:79)
     at com.ibm.ws.webcontainer.srt.WebAppInvoker.handleInvocationHook(WebAppInvoker.java:201)
     at com.ibm.ws.webcontainer.cache.invocation.CachedInvocation.handleInvocation(CachedInvocation.java:71)
     at com.ibm.ws.webcontainer.cache.invocation.CacheableInvocationContext.invoke(CacheableInvocationContext.java:114)
     at com.ibm.ws.webcontainer.srp.ServletRequestProcessor.dispatchByURI(ServletRequestProcessor.java:186)
     at com.ibm.ws.webcontainer.oselistener.OSEListenerDispatcher.service(OSEListener.java:334)
     at com.ibm.ws.webcontainer.http.HttpConnection.handleRequest(HttpConnection.java:56)
     at com.ibm.ws.http.HttpConnection.readAndHandleRequest(HttpConnection.java:610)
     at com.ibm.ws.http.HttpConnection.run(HttpConnection.java:431)
     at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:593)
i will be thankfull if any one have any idea about it.....
waiting for your immediate response

Hi Junaid,
Your code can be work correctly on different servers or with other records but it can not be handled with buffer or autoflush,
I had same problem a few weeks ago. And lastly I had to control before printing any output. My application was working on WebSphere but not on Tomcat, so it is general problem.
The only way if you have to put some output before sending redirect:
When you want to redirect the page, write window.location = ... (javascript code).
When page is loaded automatically will be redirected to the page you want. But of course it is a bit slow.
Good Luck,
isturk.

Similar Messages

  • Java.lang.IllegalStateException: Cannot forward a response that is

              Hello,
              Went through the article
              http://dev2dev.bea.com/articles/platform7_feature.jsp
              I thought if you have a workaround for the following issue.
              Any help to solve this issue is much appreciated.
              thx,
              -Sujatha.
              I am using JATO framework and have developed JSP's.
              Running an application on top of weblogic 6.1 sp4 container.
              The OS is Solaris 5.8.
              Every time i access the jsp's, getting the following exception.
              java.lang.IllegalStateException: Cannot forward a response that is
              already committed
              at
              weblogic.servlet.internal.RequestDispatcherImpl.forward(RequestDispatcherImpl.java:132)
              at
              com.iplanet.jato.view.ViewBeanBase.forward(ViewBeanBase.java:346)
              at
              com.iplanet.jato.view.ViewBeanBase.forwardTo(ViewBeanBase.java:267)
              at
              com.iplanet.am.console.base.ConsoleServletBase.onUncaughtException(ConsoleServletBase.java:240)
              at
              com.iplanet.jato.ApplicationServletBase.fireUncaughtException(ApplicationServletBase.java:1023)
              at
              com.iplanet.jato.ApplicationServletBase.processRequest(ApplicationServletBase.java:469)
              at
              com.iplanet.jato.ApplicationServletBase.doPost(ApplicationServletBase.java:324)
              at
              com.iplanet.jato.ApplicationServletBase.doGet(ApplicationServletBase.java:294)
              at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
              at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
              at
              weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:262)
              at
              weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:198)
              at
              weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:2637)
              at
              weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2359)
              at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:139)
              at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
              

    thank you  dvohra21  the application is deployed in development .Its not session inactivity because this happen when l'm busy using the application ,reducing the application speed .

  • Java.lang.IllegalStateException: Cannot forward ...

    as OutputStream or Writer has already been obtained.
    Getting this error. Using
    Jdk1.3.1_01 with Tomcat. This did NOT happen in JavaWebServer2.0 (30 day demo version).
    This is the part of the code that is giving me the problems.
    RequestDispatcher showDispatcher = getServletContext().getRequestDispatcher(showService);
    showDispatcher.forward(req,res);
    What I am doing is using this as a central servlet that all jsp pages must go through to get to a servlet, which in turn returns to a jsp page.
    Now I will note this, as i've seen before in other similar requests. I am NOT using any Printwriters in this servlet.
    The "showService" is a hidden field on the request jsp page that tells this servlet where to go afterwards.
    As I said before, this worked with NO problems at all. Considering I wanted to get away from JWS2, and go to Tomcat, this is the problem it gave me. I have been able to get all JSP pages to work. Servlets all go through this, so i didn't want to change all my servlets and jsp pages to go direct to the servlets. (Security thing).
    Thanks to anyone who can help me out.
    ...Ordio

    taskDispatcher.include(req, res);
    showDispatcher.forward(req,res);you can use include and forward at the
    same time in the old Servlet/JSP version, as the
    include function will automatically flush the
    output(say the JSP) to the client, that's why
    something's written out but you don't know! while,
    apparently, forword function requires nothing shoud be
    sent to client.Makes sense to me. :)
    since the program works fine in Jave web server, i bet
    you must be using Tomcat 3.X or even older which use
    old version of Servlet/JSP specs and implementations.Ahh... that may explain why. I am using tomcat 3.2.3.
    So, either update the Tomcat to 4.0(which is yet a
    beta version), or find any other server else. (I
    assume you don't want to re-write the whole program).Yeah, you are right... I do not want to re-write everything to get it to work. I will update to Tomcat 4 (I know it is in beta, and supposedly it was supposed to be released today.)
    Yeah, i just grabbed tomcat 4, and here's the info from the Release Plan 4.0
    Sunday, September 9, 2001 Tomcat 4.0 Release Candidate 1
    Thursday, September 13, 2001 Tomcat 4.0 Release Candidate 2
    Monday, September 17, 2001 Tomcat 4.0 Final Release
    Thanks for helping me out, and letting me know that the problem is likely tomcat 3.X... I will try this out on 4, and reply later.
    ...Ordio

  • Java.lang.IllegalStateException: cannot resize buffer

              I am running Bea Weblogic 7.0.0 on Sun Solaris 2.8. I see the following error
              message appearing in the weblogic server logfile:
              java.lang.IllegalStateException: cannot resize buffer: 60 bytes have already been
              written
              Does anyone know what is causing this or a solution to this problem?
              

              Looks like you are trying to resize the buffer after writing body content to the
              response. So resize the buffer before outputting anything to the PrintWriter :)
              Thanks
              "Mukesh" <[email protected]> wrote:
              >
              >I am running Bea Weblogic 7.0.0 on Sun Solaris 2.8. I see the following
              >error
              >message appearing in the weblogic server logfile:
              >
              >java.lang.IllegalStateException: cannot resize buffer: 60 bytes have
              >already been
              >written
              >
              >Does anyone know what is causing this or a solution to this problem?
              

  • Java.lang.IllegalStateException: Cannot resize buffer - 2616 bytes have ...

    Hi ,
    I'm a newbie to Coherence. I installed Coherence Web in my Web Application . I see this exception when loading the login jsp in my application. Any thoughts ?
    jjava.lang.IllegalStateException: Cannot resize buffer - 2616 bytes have already been written (Servlet 2.3, sec. 5.1)
         at weblogic.servlet.internal.ServletResponseImpl.setBufferSize(ServletResponseImpl.java:338)
         at com.tangosol.coherence.servlet.api22.ServletResponseWrapper.setBufferSize(ServletResponseWrapper.java:266)
         at com.tangosol.coherence.servlet.api23.HttpServletResponseWrapperImpl.setBufferSize(HttpServletResponseWrapperImpl.java:262)
         at com.tangosol.coherence.servlet.api22.ServletResponseWrapper.setBufferSize(ServletResponseWrapper.java:266)
         at com.tangosol.coherence.servlet.api23.HttpServletResponseWrapperImpl.setBufferSize(HttpServletResponseWrapperImpl.java:262)
         at com.tangosol.coherence.servlet.api22.ServletResponseWrapper.setBufferSize(ServletResponseWrapper.java:266)
         at com.tangosol.coherence.servlet.api23.HttpServletResponseWrapperImpl.setBufferSize(HttpServletResponseWrapperImpl.java:262)
         at weblogic.servlet.jsp.PageContextImpl.initialize(PageContextImpl.java:74)
         at weblogic.servlet.jsp.PageContextImpl.<init>(PageContextImpl.java:110)
         at weblogic.servlet.jsp.JspFactoryImpl.getPageContext(JspFactoryImpl.java:40)
         at jsp_servlet._myjsp._jsp._tiles._common_includes.__header_universal_nav._jspService(__header_universal_nav.java:119)
         at weblogic.servlet.jsp.JspBase.service(JspBase.java:34)
         at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:226)
         at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:124)
         at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:283)
         at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
         at com.xyz.myfilter.web.filters.UserProfileFilter.doFilter(UserProfileFilter.java:48)
         at com.tangosol.coherence.servlet.SessionHelper.filter(SessionHelper.java:1090)
         at com.tangosol.coherence.servlet.api23.FilterWrapper.doFilter(FilterWrapper.java:137)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
         at atg.filter.dspjsp.PageFilter.doFilter(Unknown Source)
         at com.tangosol.coherence.servlet.SessionHelper.filter(SessionHelper.java:1090)
         at com.tangosol.coherence.servlet.api23.FilterWrapper.doFilter(FilterWrapper.java:137)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
         at weblogic.servlet.internal.RequestDispatcherImpl.invokeServlet(RequestDispatcherImpl.java:526)
         at weblogic.servlet.internal.RequestDispatcherImpl.include(RequestDispatcherImpl.java:454)
         at weblogic.servlet.jsp.PageContextImpl.include(PageContextImpl.java:163)
         at org.apache.struts.tiles.TilesUtilImpl.doInclude(TilesUtilImpl.java:99)
         at org.apache.struts.tiles.TilesUtil.doInclude(TilesUtil.java:135)
         at org.apache.struts.taglib.tiles.InsertTag.doInclude(InsertTag.java:760)
         at org.apache.struts.taglib.tiles.InsertTag$InsertHandler.doEndTag(InsertTag.java:892)
         at org.apache.struts.taglib.tiles.InsertTag.doEndTag(InsertTag.java:462)
         at jsp_servlet._myjsp._jsp._tiles._layouts.__xyz_master_layout._jsp__tag2(__xyz_master_layout.java:799)
         at jsp_servlet._myjsp._jsp._tiles._layouts.__xyz_master_layout._jspService(__xyz_master_layout.java:304)
         at weblogic.servlet.jsp.JspBase.service(JspBase.java:34)
         at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:226)
         at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:124)
         at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:283)
         at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)

              Looks like you are trying to resize the buffer after writing body content to the
              response. So resize the buffer before outputting anything to the PrintWriter :)
              Thanks
              "Mukesh" <[email protected]> wrote:
              >
              >I am running Bea Weblogic 7.0.0 on Sun Solaris 2.8. I see the following
              >error
              >message appearing in the weblogic server logfile:
              >
              >java.lang.IllegalStateException: cannot resize buffer: 60 bytes have
              >already been
              >written
              >
              >Does anyone know what is causing this or a solution to this problem?
              

  • Java.lang.IllegalStateException: cannot add non-XA Resource to global JTS t

    Hi,
    I am using JCAPS 5.1.2.
    As one of my project requirement I am invoking a jcd from page flow and that jcd uses 2 oracle otd, each oracle otd corresponds to database which resides in two different machines/hosts.
    When jcd is invoked from page flow, i got following error,
    "java.lang.IllegalStateException: cannot add non-XA Resource to global
    JTS transaction."
    [#|2007-07-17T19:13:06.209+0530|SEVERE|IS5.1.2|javax.enterprise.resource.resourceadapter|_ThreadID=17; ThreadName=Worker: 3;stacktrace-id=0;|RAR5029:Unexpected exception while registering component
    java.lang.IllegalStateException: cannot add non-XA Resource to global JTS transaction.
         at com.sun.enterprise.distributedtx.J2EETransactionManagerOpt.enlistResource(J2EETransactionManagerOpt.java:171)
         at com.sun.enterprise.resource.ResourceManagerImpl.registerResource(ResourceManagerImpl.java:97)
         at com.sun.enterprise.resource.ResourceManagerImpl.enlistResource(ResourceManagerImpl.java:71)
         at com.sun.enterprise.resource.PoolManagerImpl.getResource(PoolManagerImpl.java:142)
         at com.sun.enterprise.connectors.ConnectionManagerImpl.internalGetConnection(ConnectionManagerImpl.java:202)
         at com.sun.enterprise.connectors.ConnectionManagerImpl.allocateConnection(ConnectionManagerImpl.java:148)
         at com.stc.gjc.spi.DataSource.getConnection(DataSource.java:67)
         at com.stc.connector.oracleadapter.base.SessionImpl.connect(SessionImpl.java:130)
         at com.stc.connector.oracleadapter.OracleSession.open(OracleSession.java:98)
         at com.stc.connector.oracleadapter.OracleConnector.open(OracleConnector.java:90)
         at com.stc.connector.oracleadapter.appconn.OracleApplicationConnection.<init>(OracleApplicationConnection.java:63)
         at com.stc.connector.oracleadapter.appconn.OracleApplicationConnection.<init>(OracleApplicationConnection.java:50)
         at com.stc.connector.oracleadapter.appconn.OracleApplicationConnectionFactory.getConnection(OracleApplicationConnectionFactory.java:133)
         at com.stc.oracle.runtime.ejb.OracleEWayRuntimeHandler.initializeService(OracleEWayRuntimeHandler.java:256)
    Please let me know is there any work around for above problem
    Message was edited by:
    VenkateshSampoornam

    Hi Paul,
    Thanks for your reply. I ddidn't specify XA at page
    flow level.
    But the problem is rectified for me.
    I have two jcds in which one of them connects to two different oracle databases for e.g host A and host B.
    JCD1 connects to host A and host B[ 2 oracle otds]
    JCD2 connects to host B. [single oracle otd]
    I had three external applications for each otd
    In deployment profile, i connected two external applications to single external system for HOST B.
    When i created one more new external system for host b and moved one external application to that.
    After then the problem didn't occur again.
    null

  • Cannot login: Response already committed

    Getting this problem of "Cannot login: Response already committed " for
    /etc/designs/geometrixx/static.css .
    Has anyone faced the same kind of problem. When do we typically get it ?

    Jsp normally buffers output in a 8k buffer and write it to the output stream (i.e. "commits") it when:
    1) it is explicitly flushed
    2) the buffer overflow
    3) an jsp include is invoked
    My code is in a layout.jsp file which is referenced in a tiles-definition. The tiles definition is tiles:inserted in a top-level jsp file. I am not sure if tiles uses jsp:include or if there is a way to get jsp:foward to work in the layout.jsp.

  • Getting java.lang.IllegalStateException error with response.getOutputStream

    Hi,
    I am writer a JSP site for displaying JFreeChart. The main JSP page gets some parameters then the second page out put the chart as binary data with a Java class.
    I've located the part which generated the error, as follows:
    Code:
    OutputStream os = response.getOutputStream(); <--- this line cause the error
    response.setContentType("image/png");
    ChartUtilities.writeChartAsPNG(os, chart, 400, 300);
    (other than it, the JSP does nothing with response or out)
    Error:
    Servlet.service().for servlet jsp threw exception java.lang.IllegalStateException
    at org.apache.jasper.runtime.ServletResponseWrapperInclude.getOutputStream(ServletResponseWrapperInclude.java:62)
    at org.apache.jsp.build005f005.seriesChart_jsp.jspService(org.apache.jsp.build_005f005.seriesChart_jsp:110)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:99)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWarpper.java:325)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:245)
    I've searched this forum and google and seeking for solution for thousands times. But sadly, ways such as adding out.reset(); doesn't work.
    Would any one has some suggestion for me? Your help is very appreciated. Thanks!

    A similar question / answers from jGuru.com
    Question I used getOutputStream() of response object in JSP. Below is the code for download a file in JSP.
    %>
    <%@ page import="java.util.*,
                        java.io.*"
    %>
    <%@ page language="java"
              session="false"
              contentType="text/html; charset=8859_1"
    %>
    <%
         //read the file name.
         File fFile = new File ("D:/Ibs/outdir/batchres.conf");
         String stFileName = "batchres.conf";
         //the content type set as excel
         response.setContentType ("application/excel");
         //the header and also the Nameis set by which user will be prompted to save
         response.setHeader ("Content-Disposition", "attachment;filename=\""+stFileName+"\"");
         //Open an input stream to the file and post the file contents thru the
         //servlet output stream to the client m/c
         InputStream isStream = null;
         ServletOutputStream sosStream = null;
         try
              //response.flushBuffer();
              isStream = new FileInputStream(fFile);
              sosStream = response.getOutputStream();
              int ibit = 256;
              while ((ibit) >= 0)
              ibit = isStream.read();
              sosStream.write(ibit);
         catch (IOException ioeException)
    sosStream.flush();
    sosStream.close();
    isStream.close();
    %>
    If run this code in Tomcat i am getting following error.. �<h1>Error: 500</h1> <h2>Location: /imu/jsp/ibUTLCmnDownloadView.jsp</h2>Internal Servlet Error:
    java.lang.IllegalStateException: getOutputStream() has already been called
         at org.apache.tomcat.facade.HttpServletResponseFacade.getWriter(Unknown Source)
         at org.apache.jasper.runtime.JspWriterImpl.initOut(Unknown Source)
         at org.apache.jasper.runtime.JspWriterImpl.flushBuffer(Unknown Source)
         at jsp.ibUTLCmnDownloadView_12._jspService(ibUTLCmnDownloadView_12.java, Compiled Code)
         at org.apache.jasper.runtime.HttpJspBase.service(Unknown Source)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java)
         at org.apache.tomcat.facade.ServletHandler.doService(Unknown Source)
         at org.apache.tomcat.core.Handler.invoke(Unknown Source)
         at org.apache.tomcat.core.Handler.service(Unknown Source)
         at org.apache.tomcat.facade.ServletHandler.service(Unknown Source)
         at org.apache.tomcat.facade.RequestDispatcherImpl.doForward(Unknown Source)
         at org.apache.tomcat.facade.RequestDispatcherImpl.forward(Unknown Source)
         at JP.co.Hitachi.soft.IBS.Common.Servlet.ibUTLCmnDownloadScrGenServlet.doPost(ibUTLCmnDownloadScrGenServlet.java:75)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java)
         at org.apache.tomcat.facade.ServletHandler.doService(Unknown Source)
         at org.apache.tomcat.core.Handler.invoke(Unknown Source)
         at org.apache.tomcat.core.Handler.service(Unknown Source)
         at org.apache.tomcat.facade.ServletHandler.service(Unknown Source)
         at org.apache.tomcat.core.ContextManager.internalService(Unknown Source)
         at org.apache.tomcat.core.ContextManager.service(Unknown Source)
         at org.apache.tomcat.modules.server.Http10Interceptor.processConnection(Unknown Source)
         at org.apache.tomcat.util.net.TcpWorkerThread.runIt(Unknown Source)
         at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(Unknown Source)
         at java.lang.Thread.run(Thread.java:479)
    Answer
    Don't know if this will help--your code worked as is on my system (J2SDK 1.4.1, Tomcat 4.1.12, Linux)--but you're setting the content-type twice, and to two different values. In the page directive, you specify contentType="text/html; charset=8859_1", and then in the scriptlet, you do a response.setContentType ("application/excel");. Try changing the one in the page directive and deleting the one in the scriptlet. The servlet container may be calling getOutputStream() when it sees the text MIME type so it can prepare the out built-in variable.
    Also, according to the J2EE design patterns, JSP's should only be used to produce text output. Any binary output (such as Excel files) should be produced with servlets--otherwise, the JSP becomes one big scriptlet (like this one).
    If you still want to do this with a JSP, you might want to take out your try ... catch block since you're not doing anything with it. Doing so will allow you to let the servlet container handle the errors (i.e. specify error pages in the web application deployment descriptor). Either that, or at least put the close() and flush()calls in it since they can throw IOExceptions, too. :)
    Finally, you should never close the servlet's output stream. Leave that up to the servlet container.
    Is this item helpful? yes no Previous votes Yes: 2 No: 3
    To transfer file from client to server using jsp programs
    chalpati Rao, Aug 11, 2004 [replies:1]
    How to Download File using JSP program
    Re: To transfer file from client to server using jsp programs
    Saravanan Mani, Aug 24, 2004
    Try restarting the server.It worked for me (ie.you did all the code changes mentioned in the previous reply)
    Breakline problems
    David Machado, Jan 27, 2005 [replies:1]
    Hi! Maybe a problem with breaklines. Try this: ------------------------------------------------------
    %><%@ // don't send breakline here!!!
    page import="java.util.*,
    java.io.*"
    %><%@ // don't send breakline here too!!!
    page language="java"
    session="false"
    contentType="text/html; charset=8859_1"
    %><% // finally, don't send breakline here!!!
    //read the file name.
    File fFile = new File ("D:/Ibs/outdir/batchres.conf");
    String stFileName = "batchres.conf";
    //the content type set as excel
    response.setContentType ("application/excel"); // twice???
    //the header and also the Nameis set by which user will be prompted to save
    response.setHeader ("Content-Disposition", "attachment;filename=\""+stFileName+"\"");
    //Open an input stream to the file and post the file contents thru the
    //servlet output stream to the client m/c
    InputStream isStream = null;
    ServletOutputStream sosStream = null;
    try
    //response.flushBuffer();
    isStream = new FileInputStream(fFile);
    sosStream = response.getOutputStream();
    int ibit = 256;
    while ((ibit) >= 0)
    ibit = isStream.read();
    sosStream.write(ibit);
    catch (IOException ioeException)
    sosStream.flush();
    sosStream.close();
    isStream.close();
    %> // make sure that's no breakline an no spaces at the end!!
    Re: Breakline problems
    Aarthi Sivaram, Apr 19, 2005
    In the above code sosStream = response.getOutputStream(); must be removed. Use 'out' instead of sosStream i.e. out.write(""+ibit); If you look at the Java code generated for your JSP, you can find JspWriter out = null ... .. JspWriter calls response.getOutputStream(), thats why when u call getOutputStream, u get IllegalStateException. 'out' variable is available for direct use in all JSP's, like 'request'. So that can be directly used to write.
    A quick and working workaround
    Leslie Leng, May 20, 2005 [replies:1]
    I am not going to discuss the theory behind, as others gurus mentioned before me, are valid.
    In short, getOutputStream() could not be used more than once, and also it will conflict with JSPWriter's out.
    So, the quick workaround would be, at the end of the JSP page, add the following:
    out.clear();
    out = pageContext.pushBody();
    in example:
    catch(Exception e){
    System.out.print(e);
    out.clear();
    out = pageContext.pushBody();
    %>
    Re: A quick and working workaround
    ajit Pandey, Jul 15, 2005
    Thanks a ton Leslie ,it worked(Production issue) :) credit goes to you....indebted

  • Getting java.lang.IllegalStateException  when try response.sendRedirect(cv)

    hi,
    I am getting this error java.lang.IllegalStateException when i am trying to send response to a jsp page
    here is my code
    try{
              Class.forName("com.mysql.jdbc.Driver");
              Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root","root");
              PreparedStatement statement = con.prepareStatement(sql);
              int i = 0;          
              i = i+1;
              statement.setString(1,designation);                    
              i = i+1;
              statement.setString(2,Address);                    
              i = i+1;
              statement.setString(3,name);               
              statement.executeUpdate();
              statement.close();
              con.close();
              catch(Exception e){
                   e.printStackTrace();
              response.sendRedirect("employee.jsp");Shoeb

    here is the error
    java.lang.IllegalStateException
         org.apache.catalina.connector.ResponseFacade.sendRedirect(ResponseFacade.java:433)
         employee.doPost(employee.java:55)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    try{
              Class.forName("com.mysql.jdbc.Driver");
              Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root","root");
              PreparedStatement statement = con.prepareStatement(sql);
              int i = 0;          
              i = i+1;
              statement.setString(1,designation);                    
              i = i+1;
              statement.setString(2,Address);                    
              i = i+1;
              statement.setString(3,name);               
              statement.executeUpdate();
              statement.close();
              con.close();
              response.sendRedirect("employee.jsp");
              catch(Exception e){
                   e.printStackTrace();
              }

  • Java.lang.IllegalStateException:Attempt to validate already invalid Region

    Hi,
    i am using jdev 11.1.1.2
    I am working in region, I drag drop the table and so on.Suddenly i start getting this error -”java.lang.IllegalStateException: Attempt to validate an already invalid RegionSite”.
    any idea how to solve it.

    check all these points..
    - Check all bindings of page. if you not able to find it then delete it and create again.
    - Add the “-Djbo.debugoutput=console” in JAVA options of the Run/Debug/Profile to see the error
    - Check if all the library references for the UI project are proper and that is also accessible.

  • Jsp:forward failed with 'Response already committed'

    I got a "Response already commited" error when using logic:forward or jsp:forward inside a JSP page fragment that is part of a Struts Tiles layout.
    Here is the code fragment included in the layout.jsp.
    <%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
    <logic:notPresent name="user" scope="session">
         <logic:forward name="login" />
    </logic:notPresent>
    Here is the error message:
    [ServletException in:/WEB-INF/tiles/verifyLogin.jsp] Exception forwarding for name login: java.lang.IllegalStateException: Cannot forward. Response already committed. (Servlet 2.3, SRV 8.4)'

    Jsp normally buffers output in a 8k buffer and write it to the output stream (i.e. "commits") it when:
    1) it is explicitly flushed
    2) the buffer overflow
    3) an jsp include is invoked
    My code is in a layout.jsp file which is referenced in a tiles-definition. The tiles definition is tiles:inserted in a top-level jsp file. I am not sure if tiles uses jsp:include or if there is a way to get jsp:foward to work in the layout.jsp.

  • Forward Request giving java.lang.IllegalStateException

    Hi Friends,
    I am using RequestDispatcher to forwrd my request from one servlet to another
    Here's the code
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.sql.*;
    public class TryServlet extends HttpServlet
    public void service(HttpServletRequest request,HttpServletResponse response)throws ServletException,IOException
    try
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    String url="jdbc:odbc:con";
    Connection con= DriverManager.getConnection(url,"scott","tiger");     
    Statement stmt=con.createStatement();
    ResultSet rst=stmt.executeQuery("select * from Projects");
    response.setContentType("text/html");
    PrintWriter out=response.getWriter();
    while (rst.next())
    String firstname=rst.getString("PIN");
    String lastname=rst.getString("ProjectTitle");
    out.println("<p> Name:"+firstname+" "+lastname+"");     
    con.close();
    RequestDispatcher rd=getServletContext().getNamedDispatcher("HelloServlet");
    rd.forward(request,response);
    return;
    catch(Exception e)
    e.printStackTrace();
    I m getting the error
    java.lang.IllegalStateException: Cannot forward after response has been committed
    i need to include the two rows of tables before i forwad the request to HelloServlet
    What needs to be done?
    thanx
    Pooja

    Don't spread the generation of output over several servlets. Your first servlet should retrieve the data and your second servlet should display the data.
    Store the data retrieved as a request attribute before forwarding:
    // Data.java
    public class Data  {
      public String _firstname;
      public String _lastname;
      public data(String firstname, String lastname)  {
        _firstname = firstname;
        _lastname = lastname;
        return;
    //  TryServlet.java
    public class TryServlet extends HttpServlet
      List list = new ArrayList();
      while (rst.next())  {  //  store data in list
        String firstname=rst.getString("PIN");
        String lastname=rst.getString("ProjectTitle");
        Data data = new data(firstname, lastname);
        list.add(data);
      con.close();
      request.setAttribute("list", list);  //  store list in request
      RequestDispatcher rd=getServletContext().getNamedDispatcher("HelloServlet");
      rd.forward(request,response);  // list is forwarded as well
      return;
    }In HelloServlet, you get the request's attribute and display the data:
      List list = (List)request.getAttribute("list");  //  retrieve list from request
      Iterator it = list.iterator();
      while (it.hasNext())  {  //  retrieve data from list and display
        Data data = (Data)it.next();
        out.println("<p>Name: " + data._firstname + " " + data._lastname + "</p>");
      }Btw, for displaying the data, a JSP will do better.
    Two Bears.

  • IllegalStateException: Cannot forward to same URI

    I am getting the below error. Can some one explain
    this error? Thank you.
    500 Internal Server Error
    com.livesoftware.jsp.JSPServlet:
    java.lang.IllegalStateException: Cannot forward to same URI '/telecom/ErrorJSP.jsp'
    What does this mean and what should I look for.

    It seems that your error page has an error, and tries to forward to itself.
    This would result in an endless loop.
    Check the page /telecom/ErrorJSP.jsp to see why it would forward to itself.

  • Session block java.lang.IllegalStateException

    hello all
    i had developed a jsp but it gives the following error
    session block java.lang.IllegalStateException: Cannot call sendRedirect() after the response has been committed
    shd i paste code here?
    regards and tanks in advance
    hema

    The error is fairly self explanatory.
    "Cannot call sendRedirect() after the response has been committed "
    Once you start sending a response, you can't suddenly change your mind. JSP pages have a "buffer" to give you some leeway. The default buffer size is 8kb.
    The response is committed when the buffer is flushed. This happens when:
    - the buffer gets full
    - you explicitly call flush()
    There are two possible solutions
    1 - Make sure all forward/redirects happen as close to the top of the page as possible. This means they have a good chance of happening before the buffer gets full
    2 - make the buffer larger <%@ page buffer="16kb" %>
    Also after you do a forward/redirect, then make sure you return directly after it. Just because you call redirect, doesn't mean the page stops executing.
    Cheers,
    evnafets

  • Getting error Servlet failed with Exception java.lang.IllegalStateException

    Hi
    I am getting this error throughout the server when i am trying to download a pdf from that page.
    Im attaching the error console
    2011 5:10:26 PM CEST> <Error> <HTTP> <aczocc08x.vfcz.dc-ratingen.de> <ShopSrv1_1_pre> <[ACTIVE] ExecuteThread: '7' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <> <1306163426535> <BEA-101020> <[weblogic.servlet.internal.WebAppServletContext@172d19e - appName: 'OCC', name: '/shop', context-path: '/shop'] Servlet failed with Exception
    java.lang.IllegalStateException: Cannot resize buffer - 76438 bytes have already been written (Servlet 2.3, sec. 5.1)
         at weblogic.servlet.internal.ServletResponseImpl.setBufferSize(ServletResponseImpl.java:338)
         at weblogic.servlet.jsp.PageContextImpl.initialize(PageContextImpl.java:74)
         at weblogic.servlet.jsp.PageContextImpl.<init>(PageContextImpl.java:110)
         at weblogic.servlet.jsp.JspFactoryImpl.getPageContext(JspFactoryImpl.java:40)
         at jsp_servlet._checkout._order.__cart_thank_45_you._jspService(__cart_thank_45_you.java:644)
         at weblogic.servlet.jsp.JspBase.service(JspBase.java:34)
         at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:226)
         at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:124)
         at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:283)
         at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
         at vodafone.servlet.security.HttpsEnforcingFilter.doFilter(HttpsEnforcingFilter.java:39)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
         at atg.servlet.pipeline.TailPipelineServlet.service(TailPipelineServlet.java:90)
         at atg.servlet.pipeline.PipelineableServletImpl.passRequest(PipelineableServletImpl.java:116)
         at atg.servlet.pipeline.DispatcherPipelineServletImpl.service(DispatcherPipelineServletImpl.java:202)
         at atg.servlet.pipeline.PipelineableServletImpl.passRequest(PipelineableServletImpl.java:116)
         at atg.servlet.pipeline.PipelineableServletImpl.service(PipelineableServletImpl.java:279)
         at vodafone.dynamo.servlet.LocaleRedirector.service(LocaleRedirector.java:75)
         at atg.servlet.pipeline.PipelineableServletImpl.passRequest(PipelineableServletImpl.java:116)
         at atg.servlet.pipeline.PipelineableServletImpl.service(PipelineableServletImpl.java:279)
         at atg.servlet.dafpipeline.RecordingServlet.service(RecordingServlet.java:280)
         at atg.servlet.pipeline.PipelineableServletImpl.passRequest(PipelineableServletImpl.java:116)
         at atg.servlet.http.CookieBufferServlet.service(CookieBufferServlet.java:97)
         at atg.servlet.pipeline.PipelineableServletImpl.passRequest(PipelineableServletImpl.java:116)
         at atg.userprofiling.ExpiredPasswordServlet.service(ExpiredPasswordServlet.java:356)
         at atg.servlet.pipeline.PipelineableServletImpl.passRequest(PipelineableServletImpl.java:116)
         at atg.servlet.pipeline.MimeTyperPipelineServlet.service(MimeTyperPipelineServlet.java:206)
         at atg.servlet.pipeline.PipelineableServletImpl.passRequest(PipelineableServletImpl.java:116)
         at atg.droplet.DropletEventServlet.service(DropletEventServlet.java:565)
         at atg.servlet.pipeline.PipelineableServletImpl.passRequest(PipelineableServletImpl.java:116)
         at atg.servlet.sessionsaver.SessionSaverServlet.service(SessionSaverServlet.java:2442)
         at atg.servlet.pipeline.PipelineableServletImpl.passRequest(PipelineableServletImpl.java:116)
         at atg.commerce.order.CommerceCommandServlet.service(CommerceCommandServlet.java:128)
         at atg.servlet.pipeline.PipelineableServletImpl.passRequest(PipelineableServletImpl.java:116)
         at atg.commerce.promotion.PromotionServlet.service(PromotionServlet.java:191)
         at atg.servlet.pipeline.PipelineableServletImpl.passRequest(PipelineableServletImpl.java:116)
         at atg.userprofiling.AccessControlServlet.service(AccessControlServlet.java:602)
         at atg.servlet.pipeline.PipelineableServletImpl.passRequest(PipelineableServletImpl.java:116)
         at atg.userprofiling.PageEventTriggerPipelineServlet.service(PageEventTriggerPipelineServlet.java:169)
         at atg.servlet.pipeline.PipelineableServletImpl.passRequest(PipelineableServletImpl.java:116)
         at atg.userprofiling.SessionEventTrigger.service(SessionEventTrigger.java:461)
         at atg.servlet.pipeline.PipelineableServletImpl.passRequest(PipelineableServletImpl.java:116)
         at vodafone.servlets.ServletHelper.service(ServletHelper.java:34)
         at atg.servlet.pipeline.PipelineableServletImpl.passRequest(PipelineableServletImpl.java:116)
         at vodafone.dynamo.servlet.DefaultCatalogFixer.service(DefaultCatalogFixer.java:54)
         at atg.servlet.pipeline.PipelineableServletImpl.passRequest(PipelineableServletImpl.java:116)
         at atg.commerce.profile.VodafoneSSOProfileRequestServlet.service(VodafoneSSOProfileRequestServlet.java:231)
         at atg.servlet.pipeline.PipelineableServletImpl.passRequest(PipelineableServletImpl.java:116)
         at atg.userprofiling.ProfileRequestServlet.service(ProfileRequestServlet.java:480)
         at atg.servlet.pipeline.PipelineableServletImpl.passRequest(PipelineableServletImpl.java:116)
         at vodafone.session.SessionSynchronizationServlet.service(SessionSynchronizationServlet.java:38)
         at atg.servlet.pipeline.PipelineableServletImpl.passRequest(PipelineableServletImpl.java:116)
         at atg.servlet.pipeline.DynamoPipelineServlet.service(DynamoPipelineServlet.java:469)
         at atg.servlet.pipeline.PipelineableServletImpl.passRequest(PipelineableServletImpl.java:116)
         at atg.servlet.pipeline.PathAuthenticationPipelineServlet.service(PathAuthenticationPipelineServlet.java:370)
         at atg.servlet.pipeline.PipelineableServletImpl.passRequest(PipelineableServletImpl.java:116)
         at atg.userprofiling.sso.PassportServlet.service(PassportServlet.java:561)
         at atg.servlet.pipeline.PipelineableServletImpl.passRequest(PipelineableServletImpl.java:116)
         at atg.servlet.security.ThreadUserBinderServlet.service(ThreadUserBinderServlet.java:91)
         at atg.servlet.pipeline.PipelineableServletImpl.passRequest(PipelineableServletImpl.java:116)
         at atg.servlet.pipeline.HeadPipelineServlet.passRequest(HeadPipelineServlet.java:1100)
         at atg.servlet.pipeline.HeadPipelineServlet.service(HeadPipelineServlet.java:782)
         at atg.servlet.pipeline.PipelineableServletImpl.service(PipelineableServletImpl.java:231)
         at atg.filter.dspjsp.PageFilter.doFilter(Unknown Source)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
         at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3393)
         at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
         at weblogic.security.service.SecurityManager.runAs(Unknown Source)
         at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2140)
         at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2046)
         at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1366)
         at weblogic.work.ExecuteThread.execute(ExecuteThread.java:200)
         at weblogic.work.ExecuteThread.run(ExecuteThread.java:172)
    >
    Anyone has any idea or faced this issue before please guide me what is the cause, i have got a feeling that this may be because server has run out of memory.

    i havn't written anything before calling set buiffer sizeSo why does the exception message say the opposite?
    I can see that error may be because of a jsp named cart_thank-you.jspSo can I. So have a look at it. It is writing something before the other thing is calling setBufferSize().
    you can see that in erro logSo can you.

Maybe you are looking for

  • Double speed playback

    hi i am importing HDV footage from my JVC BR-HD50 deck. the problim is that after importing the footage it playes back at almost doule the speed. Has any one had this problem or know a solution to fix it? thanks in advance mike

  • MacBook Pro 13" 2.5 or 2.9 GHz?

    Hello Apple Community, I am currently shifting from a PC to my first MacBook and cannot seem to decide which MB Pro will suit me best. I will be a freshman in college this fall. I don't plan on using programs such as Photoshop very frequently. I rath

  • How to get MAC address from IP address in LAN

    Hi all, How to get MAC address from IP address in LAN (windows or any OS), I would have all IP addresses of my LAN, so I would like to know all MAC address. Code examples are highly appreciated. Thanks & Regards, abel...

  • Hosting a server for simple game related info, rankings, high scores, etc.

    I have a quick question about servers. I want to implement a ranking system for one of my games, the server would store player high scores and world rankings based on their score and perhaps other fairly easy stuff. Writing the server and communicati

  • Iphone 4S Camera Shutter won't open after update to iOS 5.1.1

    are other people having this issue too and if yes then how did you resolve it?