Hi,
When you use DispatchAction class we can have more than one method in our action class(I think you know this right )Now I will show a small example how to use DispatchAction class
I have a action class for my registration of a form. In that i have methods for inserting the registered data to the table, deleting some record and for modifying the record
the class will be like this
public RegAction extends DispatchAction
{
public ActionForward insertDetails(ActionMapping mapping,
ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
{
*** your code**
return mapping.findForward("inserted");
}
public ActionForward deleteDetails(ActionMapping mapping,
ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
{
*** code ***
return mapping.findForward("deleted");
}
}
This class i am mappiing as
<action mapping="/register" name="regForm" type="mypackage1.RegAction" parameter="option" input="/register.jsp">
<forward name="inserted" path="/menu.jsp"/>
<forward name="deleted" path="/login.jsp"/>
</action>
You can give the forward as you want. Now in the
jsp you have to give the form action as
<html:form action="/register?option=insertDetails">
</html:form> . This is for insertion part for delete part give option=deleteDetails.
Here insead of option you can use what name you want . Only thing is that it should match with what we are specifying as parameter in the action mapping.
there option= whatever we are giving is the method name which we want to use for that particular action
hope this will help you
Try like this