KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > struts > chain > servlet > PerformInclude


1 /*
2  * Copyright 2003,2004 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
17 package org.apache.struts.chain.servlet;
18
19
20 import javax.servlet.RequestDispatcher JavaDoc;
21 import javax.servlet.http.HttpServletRequest JavaDoc;
22 import org.apache.commons.chain.Context;
23 import org.apache.commons.chain.web.servlet.ServletWebContext;
24 import org.apache.struts.chain.AbstractPerformInclude;
25 import org.apache.struts.upload.MultipartRequestWrapper;
26
27
28 /**
29  * <p>Perform forwarding or redirection based on the specified
30  * include uri (if any).</p>
31  *
32  * @version $Rev: 54933 $ $Date: 2004-10-16 18:04:52 +0100 (Sat, 16 Oct 2004) $
33  */

34
35 public class PerformInclude extends AbstractPerformInclude {
36
37
38     // ------------------------------------------------------- Protected Methods
39

40
41     /**
42      * <p>Perform the appropriate processing on the specified
43      * include uri.</p>
44      *
45      * @param context The context for this request
46      * @param uri The uri to be included
47      */

48     protected void perform(Context context, String JavaDoc uri)
49         throws Exception JavaDoc {
50
51         ServletWebContext swcontext = (ServletWebContext) context;
52         
53         // Get the underlying request in the case of a multipart wrapper
54
HttpServletRequest JavaDoc request = swcontext.getRequest();
55         if (request instanceof MultipartRequestWrapper) {
56             request = ((MultipartRequestWrapper) request).getRequest();
57         }
58         
59         RequestDispatcher JavaDoc rd =
60                 swcontext.getContext().getRequestDispatcher(uri);
61         rd.forward(request, swcontext.getResponse());
62     }
63
64
65 }
66
Popular Tags