Response had already been committed

hello,
i have a struts application which saves a file to databse as BLOB. on click of alink this file has to be read from database and opened in browser. i do this by first reading from blob and write it to a file and then read it from the file and write to the response. i am able to read this file from databse and write it to a file on the physical drive. but i am not able to write the file in response so that it goes to browser.
i get the following error.
: java.lang.IllegalStateException: Response has already been committed.
the code snippet to write to response is as follows.
response.setContentType(oscDVO.getM_strContentType());
response.setHeader("Content-Disposition","attachment;filename=\"" + oscDVO.getM_strFileName()+"\"");
ServletOutputStream outputStream = response.getOutputStream();
File file = new File("C:\\"+oscDVO.getM_strFileName());     FileInputStream fileInputStream = null;
fileInputStream = new FileInputStream(file);
BufferedInputStream bis=new BufferedInputStream(fileInputStream);
int nByte = bis.read();
boolean b=false;
while(nByte != -1)
outputStream.write(nByte);
nByte = bis.read();
i am in urgent need of solution. i hv searched on most of the forums but hv not got any solution. if anyone has ever implemented similar knd of functionality pls help.
thanking in advance.

thnkou for ur quick response.
i tried closing the streams as well.
but the problem persists.
if i try to open a word document, the document opens properly, the same error of response committed ocurs but i think ms word truncates tthe error. but if i open the same doc file in any other editor, the error is displayed at the bottom of the correct data.
but with very small text files of less than1 kb also , i get this error.

Similar Messages

  • HELP: java.lang.IllegalStateException: Response has already been committed

    I have a little problem.
    I'm trying to draw a graph is JSP. And I did it. I'm my computer works fine with no problems. But I have a server and when I try to run the program there it appears this error message.
    My computer :
    Pentium 4 1.6 GHz
    O/S : Win2k
    Apache 3.3.1
    Tomcat 1.1.1.1
    JDK 1.3.1.01
    Oracle 9.0
    And the server :
    HP L-2000 Class Server
    O/S : Unix
    Apache 3.3.1
    Tomcat 1.1.1.1
    JDK 1.3.0.01
    Oracle 9.0
    And the error message is :
    Error: 500
    Location: /kmcp/sttssrch/Merchant/mstat-01-coupon-graph.jsp
    Internal Servlet Error:
    java.lang.IllegalStateException: Response has already been committed
         at org.apache.tomcat.core.HttpServletResponseFacade.sendError
    (HttpServletResponseFacade.java:157)
         at org.apache.jasper.runtime.JspServlet.unknownException
    (JspServlet.java:299)
         at org.apache.jasper.runtime.JspServlet.service
    (JspServlet.java:377)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at org.apache.tomcat.core.ServletWrapper.handleRequest
    (ServletWrapper.java:503)
         at org.apache.tomcat.core.ContextManager.service
    (ContextManager.java:559)
         at
    org.apache.tomcat.service.connector.Ajp12ConnectionHandler.processConnect
    ion(Ajp12ConnectionHandler.java:156)
         at org.apache.tomcat.service.TcpConnectionThread.run
    (SimpleTcpEndpoint.java:338)
         at java.lang.Thread.run(Unknown Source)
    And the library I use are :
    import="java.awt.*, java.awt.image.*, com.sun.image.codec.jpeg.*, java.util.*, kmcp.*, java.sql.*,
    java.text.*"
    And when I declare a graph I use this command :
    BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
    Graphics g = image.getGraphics();
    Can anyone tell me what kind of problem and where and how can I solve it?
    Thanks.
    [email protected] ( is my e-mail address )

    Can anyone tell me what kind of problem and where and
    how can I solve it?
    Thanks.The most likely cause is that you are forwarding to or from another JSP or servlet after already sending output to the client.

  • IllegalStateException - response has already been commited

    Hi all!
              We are running WLS 5.1 sp7 on an NT box.
              Our application consists of jsp pages with <jsp:include...>, servlets
              and stateful/stateless beans. The only class that actually performs a
              forward is a servlet that serves as a dispatcher. We are getting from
              time to time an IllegalStateException - response has already been
              commited exception. This phenomena is irregular and non reproducable.
              Does anybody know if this has anything to do with a certain
              configuration issue? Has anyone encountered a similar problem?
              Is there a known workaround?
              Any help would be highly appreciated.
              Thanks,
              Eran Gilboa
              SHORE Technologies
              

    You are getting the illegal state exception because somewhere between the
              intercept of the request by a jsp/servlet and your
              requestDispatcher.forward(request, response), a class along the way is
              calling either the getInputStream() method or the getReader() method of
              javax.servlet.ServletRequest. Once you call either of these methods to
              read from the ServletInputStream() you may not be able to do a forward.
              I am having the same problem see my post from today. I have no idea how
              to get around it but I have an identical exception in wl6.0sp1 and that
              is the cause and I have never seen anything like it.
              Eran Gilboa wrote:
              > Hi all!
              > We are running WLS 5.1 sp7 on an NT box.
              > Our application consists of jsp pages with <jsp:include...>, servlets
              > and stateful/stateless beans. The only class that actually performs a
              > forward is a servlet that serves as a dispatcher. We are getting from
              > time to time an IllegalStateException - response has already been
              > commited exception. This phenomena is irregular and non reproducable.
              > Does anybody know if this has anything to do with a certain
              > configuration issue? Has anyone encountered a similar problem?
              > Is there a known workaround?
              >
              > Any help would be highly appreciated.
              >
              > Thanks,
              >
              > Eran Gilboa
              > SHORE Technologies
              

  • [ServletException in:VIView1_Browse.do] Response has already been committed

    Hi,
    I have a JSP-Struts application. By the default generation, JDeveloper build a main.html Page. This page have many Frames and one Frame is "navFrame". On this frame I have a link for a JSP Page : Browse. The call is OK. No Problems.
    No I have another Page with Tiles :
    <template:insert page="IMDLayout.jsp" flush="true">
    <template:put name="title" value="Invoices Interface" />
    <template:put name="header" value="/tiles/common/header.jsp" />
    <template:put name="footer" value="/tiles/common/footer.jsp" />
    <template:put name="menu" value="/tiles/common/menu.jsp" />
    <template:put name="body" value="VInvoiceUsersView1_Browse.do" />
    </template:insert>
    The "body" Tiles call the same JSP Page as the link on the "navFrame", but now I have the following error :
    [ServletException in:VInvoiceUsersView1_Browse.do] Response has already been committed'
    Why ?
    Please help me, I need a solution. Does somebody use BC4J/Struts/Tiles ? Any Experience ? Problem ?
    Thanks
    Yves

    This is a somewhat common problem for people who are using Struts and frames.
    What I have found to work was to create an action which calls the page (say index.jsp) which then sets up the frames or tiles..

  • Viwer export error "The response has already been committed"

    Hi,
    When use export report button from CrystalReportViewer, always download a html file with error message "The response has already been committed".
    Why does this issue occur, and how can it be resolved?
    I make a servlet which invoke to processHttpRequest. This is the code where viewer si configurated:
              Object rptSrc = null;
              rptSrc = factoryPS.openReportSource(oInfoObject, Locale.ENGLISH);
                 // use reportsource to initialize viewer
                 CrystalReportViewer viewer = new CrystalReportViewer();
                   try {
                   viewer.setReportSource(rptSrc);
                   } catch (ReportSDKExceptionBase e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                 // initialize display characteristics
                 viewer.setDisplayPage(true);
                 viewer.setDisplayGroupTree(true);
                 viewer.setDisplayToolbar(true);
                 viewer.setGroupTreeWidthUnit(CrHtmlUnitEnum.crHtmlUnitPixel);
                 viewer.setGroupTreeWidth(125);
                 viewer.setHasRefreshButton(true);
                 viewer.setHasExportButton(true);
                 viewer.setHasGotoPageButton(true);
                 viewer.setHasLogo(false);
                 viewer.setHasPageNavigationButtons(true);
                 viewer.setHasPrintButton(false);
                 viewer.setHasSearchButton(true);
                 viewer.setHasToggleGroupTreeButton(true);
                 viewer.setOwnPage(true);
                 viewer.setName("CrystalReportViewer");
                 viewer.setProductLocale(Locale.ENGLISH);
                 viewer.setPrintMode(CrPrintMode.ACTIVEX);
                     viewer.processHttpRequest(request,response,
                                    getServletConfig().getServletContext(),null);
              response.flushBuffer ();
                 viewer.dispose();         
    thanks in advance...

    I have discovered my error.
    To make proofs and show traces defined and use out object.
    PrintWriter out = response.getWriter();
    And this collision with viewer.processHttpRequest(request, response, context, null)
    Thank you for your help.

  • Java.lang.IllegalStateException: Response has already been committed

    We got this error message attached to the downloaded file after calling FileDownloadRenderer. Does any one know what this means? This error prevents the PDF file to be opened by the reader but it works fine if the file type is zip.
    Thanks,
    --Sining fang                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    Hi Gabrielle,
    Here is the stack dump. By the way, the FileDownloadRenderer() was called from an event handler, not from the pageBroker.
    Thanks,
    --Sining
    <PRE>java.lang.IllegalStateException: Response is already committed!
    <br>     void com.evermind[Oracle9iAS (9.0.3.0.0) Containers for J2EE].server.http.EvermindHttpServletResponse.setContentType(java.lang.String)
    <br>          EvermindHttpServletResponse.java:1027
    <br>     void oracle.cabo.ui.ServletRenderingContext.prepareResponse(java.lang.String, boolean)
    <br>     void oracle.cabo.servlet.ui.UINodePageRenderer.renderPage(oracle.cabo.servlet.BajaContext, oracle.cabo.servlet.Page)
    <br>     void oracle.cabo.servlet.AbstractPageBroker.renderPage(oracle.cabo.servlet.BajaContext, oracle.cabo.servlet.Page)
    <br>     oracle.cabo.servlet.Page oracle.cabo.servlet.PageBrokerHandler.handleRequest(oracle.cabo.servlet.BajaContext)
    <br>     void oracle.cabo.servlet.UIXServlet.doGet(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
    <br>     void oracle.cabo.servlet.UIXServlet.doPost(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
    <br>     void javax.servlet.http.HttpServlet.service(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
    <br>          HttpServlet.java:760
    <br>     void javax.servlet.http.HttpServlet.service(javax.servlet.ServletRequest, javax.servlet.ServletResponse)
    <br>          HttpServlet.java:853
    <br>     void com.evermind[Oracle9iAS (9.0.3.0.0) Containers for J2EE].server.http.ServletRequestDispatcher.invoke(javax.servlet.ServletRequest, javax.servlet.ServletResponse)
    <br>          ServletRequestDispatcher.java:721
    <br>     void com.evermind[Oracle9iAS (9.0.3.0.0) Containers for J2EE].server.http.ServletRequestDispatcher.forwardInternal(javax.servlet.ServletRequest, javax.servlet.http.HttpServletResponse)
    <br>          ServletRequestDispatcher.java:306
    <br>     boolean com.evermind[Oracle9iAS (9.0.3.0.0) Containers for J2EE].server.http.HttpRequestHandler.processRequest(com.evermind[Oracle9iAS (9.0.3.0.0) Containers for J2EE].server.ApplicationServerThread, com.evermind[Oracle9iAS (9.0.3.0.0) Containers for J2EE].server.http.EvermindHttpServletRequest, com.evermind[Oracle9iAS (9.0.3.0.0) Containers for J2EE].server.http.EvermindHttpServletResponse, java.io.InputStream, java.io.OutputStream, boolean)
    <br>          HttpRequestHandler.java:767
    <br>     void com.evermind[Oracle9iAS (9.0.3.0.0) Containers for J2EE].server.http.HttpRequestHandler.run(java.lang.Thread)
    <br>          HttpRequestHandler.java:259
    <br>     void com.evermind[Oracle9iAS (9.0.3.0.0) Containers for J2EE].server.http.HttpRequestHandler.run()
    <br>          HttpRequestHandler.java:106
    <br>     void EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run()
    <br>          PooledExecutor.java:803
    <br>     void java.lang.Thread.run()
    <br>          Thread.java:

  • Internal servlet error :response has already been commited

    Does anyone knows what this error message means and how to solve the problem ? ?

    Hi,
    I am using struts framework, I do have a module export to excel, where in some big Mb's of data can be exported to excel by a client. As part o the implementation I have an action which calls a DAO object. This DAO object dumbs the whole data to excel File. The action picks up this file and writes the whole thing to the ServletOutputStream. In the logs I am finding a Response Already commited exception
    " [6/22/06 6:24:09:830 EDT] 110d2e6a WebGroup E SRVE0026E: [Servlet Error]-[Cannot forward. Response already committed. &#40;Servlet 2.3, SRV 8.4&#41;]: javax.servlet.ServletException: Cannot forward. Response already committed. (Servlet 2.3, SRV 8.4)
    I fear this is causing memory leaks and eating up the whole CPU resources on the web-server, which is causing us to restart the JVM frequently.
    Can any one help me in fixing this issue.
    Thanks and Regards,
    Hari
    The code which downloads the excel file is :
    ========================================================
    private void downLoadTheExcelFile(String fileName, HttpServletResponse response) throws IOException {
    FileInputStream inputStream = new FileInputStream(fileName);
    boolean flag = true;
    response.setHeader("Content-Disposition", "attachment;filename=ECOMatrix.xls");
    response.setContentType("application/vnd.ms-excel");
    char c = '\u5000';
    ServletOutputStream servletOutputStream = response.getOutputStream();
    BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(servletOutputStream);
    int abyte0 = 0;
    while ((abyte0=inputStream.read()) != -1) {
    bufferedOutputStream.write(abyte0);
    inputStream.close();
    bufferedOutputStream.flush();
    File file = new File(fileName);
    file.delete();
    /* /opt/httpd/logs/apps/ecom/ecom-9962/EcoMatrix1141911660345.xls */
    ========================================================

  • RE:Error 500 Response has already been committed

    Hi:
    I was going through the JSP forums to figure out the solution for fixing the error:
    IllegalStateException Response already committed
    I put the following two lines on the top of my JSP page as suggested to someone in the forum:
    <%@ page autoFlush="false" %>
    <%@ page buffer="16kb" %>
    However, I still get the same error:
    Response already committed
    When I run the same JSP from within JBuilder4 IDE, everything works fine.
    I am following is the JSP file that I am trying to run:
    <HTML>
    <HEAD>
    <jsp:useBean id="Jsp1BeanId" scope="session" class="jspdb12.Jsp1Bean" />
    <jsp:setProperty name="Jsp1BeanId" property="*" />
    <TITLE>
    Jsp1
    </TITLE>
    </HEAD>
    <BODY>
    <%@ page autoflush="false" %>
    <%@ page buffer="32kb" %>
    <H1>
    JBuilder Generated JSP
    </H1>
    <FORM method="post">
    <P>Version number is:<%= Jsp1BeanId.getVersionNumber() %>
    <P>Maximum # of sessions is:<%= Jsp1BeanId.getMaxSessions() %>
    <P>Session :<%= Jsp1BeanId.getOpenSession() %>
    <P>Open File:<%= Jsp1BeanId.getOpenFile() %>
    <P>FCL Record is:<%= Jsp1BeanId.getReadRecord() %>
    <P>A field from FCL record is:<%= Jsp1BeanId.getReadField() %>
    <P>A value from a field of FCL record is:<%= Jsp1BeanId.getReadValue() %>
    <P>A Subvalue from a value of a field of FCL record is:<%= Jsp1BeanId.getReadSubvalue() %>
    <BR>
    </FORM>
    </BODY>
    </HTML>
    I can run the same JSP from within JBuilder4 IDE.
    What am I doing wrong?
    Please help!!!!!
    Thanks.
    Rino

    this page shows how flush="autoFalse" throws an exception when the buffer's full.
    http://www.javacamp.org/scwcd/course/8_1.html
    maybe you need an out.flush statement or out.clear() at the end of the page.

  • Response has already been committed

    can any tell me Y suchan exception occurs & solution
    its urgent Plz.
    Thanx

    Possible Situation:-
    If you are using function ConnectionObject.setCommit(false);
    and without making ConnectionObject.setCommit(true) if you try to redirect to some other page, it gives this error.
    Solution:-
    Before redirecting make sure you add this code
         ConnectionObject.setCommit(true);

  • APP-FND-01929: This responsibility has already been assigned to this user

    Dear All,
    While adding a new responsibility in the User Screen, I am getting the following Error:
    APP-FND-01929: This responsibility has already been assigned to this user. Please eneter a different responsibility.
    But in the list of responsibilities this particular responsibility is not added before..
    What will be the cause of this problem..
    How can I overcome this situation.. Please update...
    Many Thanks in advance.....

    Hi,
    As per your other thread, I believe you have restored couple of tables from your backup and this is not supported. In order to have everything running properly, then a full database restore should be done.
    Unable to login to application..
    Unable to login to application..
    Regards,
    Hussein

  • HT201209 My wife purchased an iTunes gift card for me and I scratched off the back to get the code and when I entered it to redeem it told me that it had already been redeemed what do I do?

    My wife purchased an iTunes gift card for me and I scratched off the back to get the code and when I entered it to redeem it told me that it had already been redeemed what do I do?

    Try Here  >  http://support.apple.com/kb/TS1292
    If no joy...
    Contact iTunes Customer Service and request assistance
    Use this Link  >  Apple  Support  iTunes Store  Contact
    And there is this...
    http://www.apple.com/hk/en/support/itunes/store/giftcard/

  • PHPCART A session had already been started

    Hi,
    I doing a cart for a client, that just requeried, that his
    cart send by e-mail all products that the users choice in the
    catalog. that's works fine...
    but I have a session error every new item select, and display
    in the cart. any one can help me to fix this?.
    I based all with this tuturial..
    http://www.adobe.com/devnet/dreamweaver/articles/php_cart.html
    The error is this..
    Notice: A session had already been started - ignoring
    session_start() in D:\www\peachpit\php_cart\db.php on line 41
    Warning: Cannot modify header information - headers already
    sent by (output started at D:\www\shopcorp\php_cart\db.php:41) in
    D:\www\shopcorp\php_cart\db.php on line 42
    thanks for any help with this?
    this is the code..
    <?php
    // This page contains the connection routine for the
    // database as well as getting the ID of the cart, etc
    $dbServer = "localhost";
    $dbUser = "root";
    $dbPass = "";
    $dbName = "cart";
    function ConnectToDb($server, $user, $pass, $database)
    // Connect to the database and return
    // true/false depending on whether or
    // not a connection could be made.
    $s = @mysql_connect($server, $user, $pass);
    $d = @mysql_select_db($database, $s);
    if(!$s || !$d)
    return false;
    else
    return true;
    function GetCartId()
    // This function will generate an encrypted string and
    // will set it as a cookie using set_cookie. This will
    // also be used as the cookieId field in the cart table
    if(isset($_COOKIE["cartId"]))
    return $_COOKIE["cartId"];
    else
    // There is no cookie set. We will set the cookie
    // and return the value of the users session ID
    session_start();
    setcookie("cartId", session_id(), time() + ((3600 * 24) *
    30));
    return session_id();
    ?>

    I sorry, I doble click the send button, that is why that
    appears doble this post..
    Sorry sorry, please some body know about this session
    problem?
    carolina

  • Attempted to redeem free upgrade to Mountain Lion today but App store said the code had already been used... though it hadn't

    I was in the process of redeeming my free upgrade to Mountain Lion today, and received a message in the "redeem" section of the App store that the redemption code had already been used. It hadn't been, unless there's a glitch in Apple's system that assigns codes. I accidentally clicked the submit button twice within a few seconds (believing I hadn't clicked it the first time, as nothing on the page indicated that I had submitted the form), as I was attempting to "redeem" my free upgrade.
    Any ideas of what to do would be great. I'm brand new to the Mac world, and am interested in running the most up-to-date OS, especially since I've just procured the very top of the line new Macbook Pro w/Retina display, etc.
    Thanks,

    The App Store has a forum area where experts await with answers:
    https://discussions.apple.com/community/mac_app_store

  • While using my pad it suddenly stopped and stated that I neede to activate it. Now it wont activate even though it had already been activated. What do I do?

    while using my pad it suddenly stopped and stated that I neede to activate it. Now it wont activate even though it had already been activated. What do I do?

    Everytime I try to do an activation it later tells me that it could not activate because the activation server is temporarily unavailable. I ready to throw it.

  • My redemption code had already been used. Where do i get a new one?

    Hi,
    I was trying to download the creative adobe on my macbook.
    I made a mistake and had to refresh the page but i already used my redemption code.
    Now it says my code had already been used and i can't use it again which means i can't download the adobe pack...
    Now what??

    Hello,
    best would be in my eyes you contact Adobe here Contact Customer Care and click throug the headlines. If necessary and for further questions use the chat, I had the best experiences. I quote from Adobe's employee Preran: The chat button is activated as soon as there is an agent available to help.
    In addition two links
    http://helpx.adobe.com/contact.html?step=CCSN_adobe-id-signing-in and
    http://helpx.adobe.com/creative-cloud/kb/unable-login-creative-cloud-248.html
    They to end in the question "Still need help? Contact us." (See above)
    Good luck!
    Hans-Günter

Maybe you are looking for