1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package org.apache.struts.actions;
22
23 import org.apache.struts.action.ActionForm;
24 import org.apache.struts.action.ActionForward;
25 import org.apache.struts.action.ActionMapping;
26
27 import javax.servlet.ServletException;
28 import javax.servlet.http.HttpServletRequest;
29 import javax.servlet.http.HttpServletResponse;
30
31 /**
32 * <p>An <strong>Action</strong> that forwards to the context-relative URI
33 * specified by the <code>parameter</code> property of our associated
34 * <code>ActionMapping</code>. This can be used to integrate Struts with
35 * other business logic components that are implemented as servlets (or JSP
36 * pages), but still take advantage of the Struts controller servlet's
37 * functionality (such as processing of form beans).</p>
38 *
39 * <p>To configure the use of this Action in your <code>struts-config.xml</code>
40 * file, create an entry like this:</p>
41 *
42 * <code> <action path="/saveSubscription" type="org.apache.struts.actions.ForwardAction"
43 * name="subscriptionForm" scope="request" input="/subscription.jsp"
44 * parameter="/path/to/processing/servlet"/> </code>
45 *
46 * <p>which will forward control to the context-relative URI specified by the
47 * <code>parameter</code> attribute.</p>
48 *
49 * @version $Rev: 471754 $ $Date: 2005-08-14 17:24:39 -0400 (Sun, 14 Aug 2005)
50 * $
51 */
52 public class ForwardAction extends BaseAction {
53
54
55 /**
56 * Process the specified HTTP request, and create the corresponding HTTP
57 * response (or forward to another web component that will create it).
58 * Return an <code>ActionForward</code> instance describing where and how
59 * control should be forwarded, or <code>null</code> if the response has
60 * already been completed.
61 *
62 * @param mapping The ActionMapping used to select this instance
63 * @param form The optional ActionForm bean for this request (if any)
64 * @param request The HTTP request we are processing
65 * @param response The HTTP response we are creating
66 * @return The forward to which control should be transferred, or
67 * <code>null</code> if the response has been completed.
68 * @throws Exception if an error occurs
69 */
70 public ActionForward execute(ActionMapping mapping, ActionForm form,
71 HttpServletRequest request, HttpServletResponse response)
72 throws Exception {
73
74 String path = mapping.getParameter();
75
76 if (path == null) {
77 throw new ServletException(messages.getMessage("forward.path"));
78 }
79
80
81 ActionForward retVal = new ActionForward(path);
82
83 return retVal;
84 }
85 }