Return null.

--- On Fri, 9/12/08, Raghuveer <[EMAIL PROTECTED]> wrote:

> From: Raghuveer <[EMAIL PROTECTED]>
> Subject: Struts 1.2.9 +Ajax Error -- java.lang.IllegalStateException
> To: user@struts.apache.org
> Date: Friday, September 12, 2008, 3:55 AM
> Hello,
> 
> I am using Ajax in my struts application.
> 
>  
> 
> From JavaScript in JSP page I call
> "employee.do?method=employee"
> 
>  
> 
>  
> 
> I get following error
> 
> java.lang.IllegalStateException: Cannot forward after
> response has been
> committed
> 
>  
> 
>  
> 
> For Ajax calls I am using struts execute method.
> 
> But Action Forward may not be used.
> 
>  
> 
> Any suggestion for this to resolve.
> 
> I assume I get this error because of "return
> mapping.findForward(strResult)";
> 
> Actual my response is already done for Ajax requests
> through
> response.getWriter,
> 
> So struts actionforward may not be used in this scenarios.
> 
>  
> 
>  
> 
>  
> 
>  
> 
>  
> 
> public ActionForward employee(final ActionMapping mapping,
> final ActionForm
> form, final HttpServletRequest request, final
> HttpServletResponse response)
> {
> 
>  
> 
>       
> 
>       
> 
>       try {
> 
>  
> 
>  
> 
> sb.append("<employee>");
> 
>            
> sb.append("<id>100</id>");
> 
>            
> sb.append("<name>john</name>");
> 
>            
> sb.append("<email>[EMAIL PROTECTED]</email>");
> 
>            
> sb.append("<phone>123123</phone>");
> 
>             sb.append("</employee >");
> 
>       
> 
>             response.setHeader("Cache-Control",
> "no-cache");
> 
>  
> 
>             out = response.getWriter();
> 
>             out.println(sb);
> 
>             out.flush();
> 
>             out.close();
> 
>       } catch (IOException e) {
> 
>             logger.error("IOException - "+e);
> 
>             handleException(e, CLASS_NAME, request);
> 
>            
> strResult=CActionPageForwards.GLOBAL_FORWARD_ACTIONERROR;   
> 
>       }finally{
> 
>             //if (out != null) {
> 
>             //    out.close();
> 
>                   //out = null;
> 
>         //}
> 
>       }
> 
>  
> 
> strResult=CActionPageForwards.FORWARD_EMPLOYEE_REQUEST;
> 
> logger.info("Result - "+strResult);
> 
> return mapping.findForward(strResult);
> 
>  
> 
> }//end execute

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to