Struts Interceptor workflow

1k views Asked by At

In Struts2 if we have define an interceptor stack and it is called in First in First Out manner. So in post processing phase what happened if one of the earlier interceptor return a control string which in result render the response to the client. I want to know that would the left interceptor will be processed or not.

1

There are 1 answers

6
Umesh Awasthi On BEST ANSWER

Well it will work like this.

Your action method will only called once the interceptor stack has been called fully.This means that once the first interceptor has been called successfully in the stack it will call the next interceptor defined in the stack and there reference being stored in the stack this chain will keep on calling till the last interceptor in the stack is called

invocation.invoke()

this call is the key to call next interceptor defined in the stack or of this is the last it will call the desired function in your action class.

now in other case suppose some of the interceptor failed say workflow it will return the result as INPUT and will halt the further execution of the interceptor and framework will output the desired JSP/Tempelate to the user.

Than comes the post -processing/cleaning in this case interceptors will be called in reverse order i.e top most or latest executed interceptor will be called first and den so on so.

The idea for this post-processing is to do any clean-up work or any other things which needs to be done (like cleaning up resources etc)

Hope this will give you some idea.