View Javadoc

1   /*
2    * Copyright 2003-2005 The Apache Software Foundation.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.apache.struts.chain.commands.servlet;
17  
18  import org.apache.struts.chain.commands.AbstractPerformInclude;
19  import org.apache.struts.chain.contexts.ActionContext;
20  import org.apache.struts.chain.contexts.ServletActionContext;
21  
22  import javax.servlet.RequestDispatcher;
23  import javax.servlet.http.HttpServletRequest;
24  
25  /***
26   * <p>Perform forwarding or redirection based on the specified include uri (if
27   * any).</p>
28   *
29   * @version $Rev: 421119 $ $Date: 2005-11-09 00:11:45 -0500 (Wed, 09 Nov 2005)
30   *          $
31   */
32  public class PerformInclude extends AbstractPerformInclude {
33      // ------------------------------------------------------- Protected Methods
34  
35      /***
36       * <p>Perform the appropriate processing on the specified include
37       * uri.</p>
38       *
39       * @param context The context for this request
40       * @param uri     The uri to be included
41       */
42      protected void perform(ActionContext context, String uri)
43          throws Exception {
44          ServletActionContext swcontext = (ServletActionContext) context;
45  
46          HttpServletRequest request = swcontext.getRequest();
47  
48          RequestDispatcher rd = swcontext.getContext().getRequestDispatcher(uri);
49  
50          rd.forward(request, swcontext.getResponse());
51      }
52  }