Perhaps this link might help you : http://jakarta.apache.org/tomcat/faq/misc.html#illegalstate
Adam Fisk wrote:
Thanks for getting back to me. I'm unfortunately still at a bit of loss here -- I'm right at the beginning of writing my first web app, so I think there's something I'm missing. When I posted yesterday, the execute(...) method of my Action subclass had simply:
return (mapping.findForward("results"));
This caused the error I posted. After reading your post, I first changed this to simply:
return null;
I was wishfully thinking that the redirect would magically happen based on the struts-config settings, but this simply resulted in nothing happening at all. Finally, I tried changing it to:
String contextPath = request.getContextPath(); String redirectUrl = contextPath + "/faces/results.jsp"; response.sendRedirect(redirectUrl); return null;
This, however, resulted in the same error I posted yesterday. Sorry for my complete lack of experience here, and thanks in advance for anyone's help. What seemingly should be obvious continues to elude me =).
-adam
On Wed, 17 Sep 2003 02:21:53 -0700, "Daniel Wang" <[EMAIL PROTECTED]>
said:
Looks like you printed something to the response before you try to do the redirect()
daniel
----- Original Message ----- From: "Adam Fisk" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, September 16, 2003 9:02 PM
Subject: getting redirect to work -- easy one?
Hopefully this is an easy one for someone to answer. I'm simply trying to set up an action-mapping that performs a redirect instead of a forward. If I use the following xml in struts-config.xml (I'm using **struts-faces**), then everything "works":
<action path="/search" type="com.wheels.struts.SearchAction" name="searchForm" scope="request" input="search"> <forward name="results" path="faces/results.jsp" /> </action>
I get an error if I change the forward to be a redirect, however, as in:
<action path="/search" type="com.wheels.struts.SearchAction" name="searchForm" scope="request" input="search"> <forward name="results" path="faces/results.jsp" redirect="true" /> </action>
The error I get is:
java.lang.IllegalStateException: Cannot forward after response has been committed
Any thoughts on this one? Is there something I need to change in my Action class to properly redirect instead of forward? Something in struts-config.xml?? I read earlier posts about creating an ActionRedirect subclass of ActionForward, but it seems like this should not be necessary. Keep in mind I'm using struts-faces -- not sure if that makes a difference.
Thanks very much.
-Adam -- Adam Fisk [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]