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