1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.seasar.cubby.action;
17
18 import java.io.IOException;
19
20 import javax.servlet.RequestDispatcher;
21 import javax.servlet.ServletException;
22 import javax.servlet.http.HttpServletRequest;
23 import javax.servlet.http.HttpServletResponse;
24
25 import org.seasar.cubby.controller.ActionContext;
26 import org.seasar.cubby.util.CubbyUtils;
27 import org.seasar.framework.log.Logger;
28 import org.seasar.framework.util.StringUtil;
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55 public class Forward extends AbstractActionResult {
56
57 private static final Logger logger = Logger.getLogger(Forward.class);
58
59 private final String path;
60
61
62
63
64
65
66
67 public Forward(final String path) {
68 this.path = path;
69 }
70
71
72
73
74
75
76 public String getPath() {
77 return this.path;
78 }
79
80
81
82
83 public void execute(final ActionContext context,
84 final HttpServletRequest request, final HttpServletResponse response)
85 throws ServletException, IOException {
86 final Action action = context.getAction();
87 final String actionDirectory = CubbyUtils.getActionDirectory(context
88 .getComponentDef().getComponentClass());
89
90 final String absolutePath;
91 if (this.path.startsWith("/")) {
92 absolutePath = this.path;
93 } else if (StringUtil.isEmpty(actionDirectory)) {
94 absolutePath = "/" + this.path;
95 } else {
96 absolutePath = "/" + actionDirectory + "/" + this.path;
97 }
98 if (logger.isDebugEnabled()) {
99 logger.log("DCUB0001", new String[] { absolutePath });
100 }
101 final RequestDispatcher dispatcher = request
102 .getRequestDispatcher(absolutePath);
103 dispatcher.forward(request, response);
104 if (logger.isDebugEnabled()) {
105 logger.log("DCUB0002", new String[] { absolutePath });
106 }
107 action.postrender();
108
109 action.getFlash().clear();
110 }
111
112
113
114
115
116
117
118 @Override
119 public void prerender(final ActionContext context) {
120 final Action action = context.getAction();
121 action.prerender();
122 }
123
124 }