connecting two struts actions

R

raavi

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
 
M

Markus

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");
}
}
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top