Hello Sagar,
The answer is quiet simple.
Action is a class that you extend, and overwrite the
execute where you put your action logic. But there is a small problem that might face you in some applications, where in a single page you might need to give the user the opportunity to choose from several actions. The problem is that the html form can have (at a time) one and only one action.
There are several solutions to this problem. One of them is to use javascript to change the form's action, then submit it. Another solution is to have a parameter in the form, and you check for it in your action, and according to the value of that parameter, you choose what to do through conditions in your code. A third solution is using
DispatchAction.
DispatchAction is simply the same the same as the second solution, except that you don't have to write the conditions yourself. All you have to do is to create the methods that you want for that action having a signature similar to that of
execute that is present in the
Action class. You'll have to change the config of the
action in the configuration file a little, to add a parameter. This parameter is going to be present in the form bean class and in the
JSP, the values of this parameter are going to be the same as the method names. According to the value, struts will automatically call the appropriate method.
Check the pdf for advanced actions in this
site. It's very informative.
[ January 30, 2008: Message edited by: Alaa Nassef ]