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.chain.commands.servlet;
22
23 import org.apache.struts.chain.commands.AbstractPerformInclude;
24 import org.apache.struts.chain.contexts.ActionContext;
25 import org.apache.struts.chain.contexts.ServletActionContext;
26 import org.apache.struts.util.RequestUtils;
27
28 import javax.servlet.RequestDispatcher;
29 import javax.servlet.http.HttpServletRequest;
30
31 /**
32 * <p>Perform forwarding or redirection based on the specified include uri (if
33 * any).</p>
34 *
35 * @version $Rev: 471754 $ $Date: 2005-11-09 00:11:45 -0500 (Wed, 09 Nov 2005)
36 * $
37 */
38 public class PerformInclude extends AbstractPerformInclude {
39
40
41 /**
42 * <p>Perform the appropriate processing on the specified include
43 * uri.</p>
44 *
45 * @param context The context for this request
46 * @param uri The uri to be included
47 */
48 protected void perform(ActionContext context, String uri)
49 throws Exception {
50 ServletActionContext swcontext = (ServletActionContext) context;
51
52 HttpServletRequest request = swcontext.getRequest();
53
54 RequestDispatcher rd = swcontext.getContext().getRequestDispatcher(uri);
55
56 rd.forward(request, swcontext.getResponse());
57 }
58
59 protected String includePath(ActionContext actionContext, String include) {
60 ServletActionContext swcontext = (ServletActionContext) actionContext;
61 String actionIdPath = RequestUtils.actionIdURL(include, swcontext.getModuleConfig(), swcontext.getActionServlet());
62 if (actionIdPath != null) {
63 return super.includePath(actionContext, actionIdPath);
64 } else {
65 return super.includePath(actionContext, include);
66 }
67
68 }
69 }