1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package examples.links;
20
21 import java.util.HashMap;
22
23 import javax.servlet.http.HttpServletRequest;
24 import javax.servlet.http.HttpServletResponse;
25
26 import org.apache.struts.action.Action;
27 import org.apache.struts.action.ActionForm;
28 import org.apache.struts.action.ActionForward;
29 import org.apache.struts.action.ActionMapping;
30
31 import examples.TestBean;
32
33 /***
34 * Perform any tasks and setup any data that
35 * must be prepared before the form is displayed.
36 *
37 * @version $Rev: 421486 $ $Date: 2006-07-12 20:37:08 -0700 (Wed, 12 Jul 2006) $
38 */
39 public class PrepareLinksAction extends Action {
40
41
42
43 /***
44 * Constructor for PrepareOptionsAction.
45 */
46 public PrepareLinksAction() {
47 super();
48 }
49
50
51
52 /***
53 * Process the request and return an <code>ActionForward</code> instance
54 * describing where and how control should be forwarded, or
55 * <code>null</code>if the response has already been completed.
56 *
57 * @param mapping The ActionMapping used to select this instance
58 * @param form The optional ActionForm bean for this request (if any)
59 * @param request The HTTP request we are processing
60 * @param response The HTTP response we are creating
61 *
62 * @exception Exception if an exception occurs
63 *
64 * @return the ActionForward to forward control to
65 */
66 public ActionForward execute(
67 ActionMapping mapping,
68 ActionForm form,
69 HttpServletRequest request,
70 HttpServletResponse response)
71 throws Exception {
72
73 HashMap parms = new HashMap();
74 parms.put("color", "Red");
75 parms.put("fruit", "Apple");
76 parms.put("animal", "Rabbit");
77 request.setAttribute("parms", parms);
78
79 TestBean bean = new TestBean();
80 request.setAttribute("testBean", bean);
81
82
83 return mapping.findForward("success");
84
85 }
86
87 }