connecting two struts actions

Discussion in 'Java' started by raavi, Nov 22, 2005.

  1. raavi

    raavi Guest

    Hi
    i am now engaged in software development involving struts
    framework.now i want to display some results processed in the first
    action and then forward to second action.where the same processing is
    carried out and the result is to be displayed in the form of a
    string.how is this possible? i have used RequestDispatcher object,but
    the program is still not working .pls do hepl me
     
    raavi, Nov 22, 2005
    #1
    1. Advertising

  2. raavi

    Markus Guest

    Try this:
    In struts-config.xml define an forward for the first action named
    success which points to the second action.
    If you return arg0.findForward("success") (arg0 = ActionMapping) your
    Request will be forwarded to the next Action.

    Example:

    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;

    import org.apache.struts.action.ActionForm;
    import org.apache.struts.action.ActionForward;
    import org.apache.struts.action.ActionMapping;

    //Forwards the Request to the Action defined in struts-config.xml under
    TestAction.
    public class TestAction extends Action {

    public ActionForward execute(
    ActionMapping arg0,
    ActionForm arg1,
    HttpServletRequest arg2,
    HttpServletResponse arg3)
    throws IOException, ServletException {

    return arg0.findForward("success");
    }
    }
     
    Markus, Nov 22, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Pavel
    Replies:
    1
    Views:
    5,970
    Pavel
    Nov 14, 2003
  2. Jun
    Replies:
    0
    Views:
    484
  3. Sebastian Millies

    [Struts] Composite actions using include?

    Sebastian Millies, Jun 29, 2004, in forum: Java
    Replies:
    0
    Views:
    375
    Sebastian Millies
    Jun 29, 2004
  4. rjweytens
    Replies:
    0
    Views:
    445
    rjweytens
    Jun 30, 2004
  5. Tyrone Slothrop

    One Form, Two Targets, Two Actions

    Tyrone Slothrop, Dec 28, 2006, in forum: Javascript
    Replies:
    5
    Views:
    159
    Jonas Raoni
    Dec 29, 2006
Loading...

Share This Page