Topic
1 reply Latest Post - ‏2013-05-08T19:10:58Z by gifty
AmitJain15
AmitJain15
6 Posts
ACCEPTED ANSWER

Pinned topic Websphere 7 - Response already Commited error

‏2013-05-02T12:50:17Z |

Hi,

Is there any configuration changes to be done to avoid this error? I have this error when I run the code on WAS 7 server. It worked on WAS 6.1 server though. Both response.sendRedirect() and RequstDispatcher both doesn't work. Not sure where to point response commited. Please advise.

Here is the code snippet.

public Boolean isUserValid(){
        String id = (String)request.getParameter("id");
        response = (HttpServletResponse) context.getExternalContext().getResponse();
        System.out.println("+++ response:"+response.isCommitted());
        if(id != null && !id.equalsIgnoreCase("")){
            HTTPTrafficManager.removeObjectInHttpSession(context,"empId");
            HTTPTrafficManager.setObjectInHttpSession(context, "empId",id);
            this.setEmpNo(id);
            if(_LOGGER.isLoggable(Level.INFO)){
                _LOGGER.info("+++++ Employee id removed from session and added empId from URL again +++" );
            }
        } else if (HTTPTrafficManager.getObjectInHttpSession(context, "empId") != null){
            this.empNo = (String)HTTPTrafficManager.getObjectInHttpSession(context, "empId");
            if(_LOGGER.isLoggable(Level.INFO)){
                _LOGGER.info("+++++ Retreived empId from session +++" );
            }
        }else{
            try {
                
//                    response.flushBuffer();
//                    response.sendRedirect(request.getContextPath()+"/faces/pn/noauth.jsp");
                    RequestDispatcher reqDispatcher = request.getRequestDispatcher(request.getContextPath()+"/faces/pn/noauth.jsp");
                    try {
                        reqDispatcher.forward(request, response);
                    } catch (ServletException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }
                
                return null ;
            } catch (IOException ioe) {
                if(_LOGGER.isLoggable(Level.SEVERE)){
                    _LOGGER.severe("???? IOException : "+ioe.getLocalizedMessage());
                }
            }
        }
    
        return true;
    }

 

Thanks

amit

Updated on 2013-05-02T12:58:21Z at 2013-05-02T12:58:21Z by AmitJain15
  • gifty
    gifty
    18 Posts
    ACCEPTED ANSWER

    Re: Websphere 7 - Response already Commited error

    ‏2013-05-08T19:10:58Z  in response to AmitJain15

    If the response is already committed then forward dispatch is not allowed per Java Servlet specification.

    If you are not able to pinpoint where the application code is committing the response then you will need to take webcontainer server traces for further analysis to find who is committing it prior to your forward dispatch.

    Get the trace string here ,                              
    http://www-01.ibm.com/support/docview.wss?rs=180&uid=swg21384592