1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package examples;
20
21 import javax.servlet.http.HttpServletRequest;
22 import javax.servlet.http.HttpServletResponse;
23
24 import org.apache.struts.action.Action;
25 import org.apache.struts.action.ActionForm;
26 import org.apache.struts.action.ActionForward;
27 import org.apache.struts.action.ActionMapping;
28
29 /***
30 * <p>An Action that forwards control via a "success" ActionFoward.</p>
31 *
32 * <p>A recommended strategy is that view pages should link only to Actions and
33 * never directly to other views. In situations where the view does not require
34 * any preparation you can use a SuccessAction, specifying the view as an
35 * ActionForward named "success" in your action mapping.</p>
36 *
37 * <p>e.g. If you configure an ActionMapping in struts-config.xml like this:</p>
38 *
39 * <pre>
40 * <action path="/prepareView"
41 * type="examples.SuccessAction">
42 * <forward name="success" path="/jsp/View.jsp"/>
43 * </action>
44 * </pre>
45 *
46 * <p>You could create a link to the view (via the Action) as follows:</p>
47 *
48 * <pre>
49 * <html:link action="/prepareView">Display 'view' page</html:link>
50 * </pre>
51 *
52 * <p>If you later change your application such that the view page requires some
53 * initialization you can change a single ActionMapping definition in
54 * struts-config.xml rather than lots of link definitions in many JSPs.</p>
55 *
56 * @version $Rev: 421486 $ $Date: 2006-07-12 20:37:08 -0700 (Wed, 12 Jul 2006) $
57 */
58 public class SuccessAction extends Action {
59
60
61
62 /***
63 * Constructor for SuccessAction.
64 */
65 public SuccessAction() {
66 super();
67 }
68
69
70
71 /***
72 * Returns the <code>ActionForward</code> named "success" if one is
73 * configured or <code>null</code>if it cannot be found.
74 *
75 * Searches first for a local forward, then a global forward.
76 *
77 * @param mapping The ActionMapping used to select this instance
78 * @param form The optional ActionForm bean for this request (if any)
79 * @param request The HTTP request we are processing
80 * @param response The HTTP response we are creating
81 *
82 * @exception Exception if mapping.findForward throws an Exception
83 *
84 * @return the "success" ActionForward, or null if it cannot be found
85 */
86 public ActionForward execute(
87 ActionMapping mapping,
88 ActionForm form,
89 HttpServletRequest request,
90 HttpServletResponse response)
91 throws Exception {
92
93 return mapping.findForward("success");
94
95 }
96
97 }