Actions are wrapped with interceptors and these configuration we kept it in struts.xml
Instead of controlling it at configuration level, I want to bypass the execution of Action/next interceptors in the stack from interceptor itself.. dynamically .. is it really possible ?
Let me explain my problem in detail here..
I need to check a cookie at interceptor and need to execute different actions based on cookie value.. I tried in below way, I am able to redirect the response to desired action and page but with exceptions. Here is the code ..
Error Message
java.lang.IllegalStateException: Cannot create a session after the response has been committed
org.apache.catalina.connector.Request.doGetSession(Request.java:2301)
But I dont want to execute the Action, instead I want to redirect/forward to some other action from interceptor. if I choose PreResultListener then it will be called before the result is being executed. ie after execution of your Action. I dont want to happen in my case. Please let me know if any thoughts
Oh; include the full source of your interceptor then. Or just look at the source for something like the workflow interceptor and see what you're doing wrong.
Did you try it by using a normal S2 result rather than doing a sendRedirect? That's a better solution anyway.
I'm pretty sure you don't want a forward anyway, since that'd show the original URL in the browser bar.
Krishna Nagadev
Ranch Hand
Joined: Jan 04, 2005
Posts: 32
posted
0
I may require to forward the request because I need to resend the same parameters that I received as part of request. That is a different problem again ;)
Can you suggest me how to redirect to S2 Action instead of response.sendRedirect() from Interceptor ?
You should stop getting the "Result already committed" error message if you remove the "return null" statement after the redirect.
Explanation:
When you return null, the default result gets executed.
Since you have already done a response.sendRedirect(), you will get the error message when you try to forward again as per the default result.