Jeff,

Assuming the code snippet in a method that returns an ActionForward, like
the execute() method itself, you can instantiate ActionForward and return
it:

else if(action.equals("sendMessage"))
{
String member = request.getParameter("member");
ActionForward forward = new ActionForward(sendMemberInvite.jsp?member=" +
member);
return forward;
}


as for the exception, I think it's becuase Struts is trying to forward to
ActionForward *after* request dispatcher committed the response. Returning a
null, again assuming that the method is returning an ActionForward, would
tell Struts to leave the response alone.

else if(action.equals("sendMessage"))
{
String member = request.getParameter("member");
RequestDispatcher view =
request.getRequestDispatcher("sendMemberInvite.jsp?member=" + member );
view.forward(request, response);
return null;
}


Hope this helps.


ATTA

On 9/30/05, Jeff Thorne <[EMAIL PROTECTED]> wrote:
>
>
> I have the following code in an action class:
>
> else if(action.equals("sendMessage"))
> {
> String member = request.getParameter("member");
> RequestDispatcher view =
> request.getRequestDispatcher("sendMemberInvite.jsp?member=" + member );
> view.forward(request, response);
> }
>
>
> This code works successfully but is causing the following error in the
> tomcat log files
>
> Servlet.service() for servlet action threw exception
> java.lang.IllegalStateException: Cannot forward after response has been
> committed
>
> Can someone shed some light on why I am getting this error and how I
> should
> handle forward
> instructions within an action class. Any help or insight would be
> appreciated.
>
> Thanks,
> Jeff
>
>

Reply via email to