Saturday, March 19, 2011

Struts2 FilterDispatcher and its Working



A FilterDispatcher is used as the Controller in Struts2. Its name in packaged Structure is org.apache.struts2.dispatcher.FilterDispatcher. Prior to using it in the application, it has to be registered in the web.xml as below.



     
The task processing going to be done in the FilterDispatcher is splitted into several subcomponents called interceptors. One of the first interceptor will be used to populate the action object.

The action method in a struts application is executed only after the properties of struts action is populated.

A String value is returned by the method of a struts action. And depending upon the returned value, the page to which control is forwarded is decided.

The view to which the action forwards need not necessarily a jsp

At first the FilterDispatcher verifies the request URI and determines the right action for it.
The mappings of  URI’s and the action classes are present in the struts.xml file found in the WEB-INF/classes directory.

FilterDispatcher does the following for eact action invocation.

1)Determines which action to invoke for a requested URI by consulting the Configuration manager
2) Interceptors registered for the action are invoked one after the other.
3)Then the action method is executed.
4)Then the FilterDispatcher executes the Result.




For details regarding Java J2ee Online Training please visit www.javatutoronline.com