KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > commons > jelly > servlet > JellyServletContext


1 /*
2  * Copyright 2002,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.commons.jelly.servlet;
18
19 import org.apache.commons.jelly.JellyContext;
20
21 import javax.servlet.ServletContext JavaDoc;
22 import java.io.InputStream JavaDoc;
23 import java.net.MalformedURLException JavaDoc;
24 import java.net.URL JavaDoc;
25
26 /**
27  *
28  * @author <a HREF="mailto:kelvint@apache.org">Kelvin Tan</a>
29  * @version 1.1
30  */

31 public class JellyServletContext extends JellyContext {
32
33     private ServletContext JavaDoc ctx;
34
35     public JellyServletContext() {
36     }
37
38     public JellyServletContext(ServletContext JavaDoc ctx) {
39         super();
40         this.ctx = ctx;
41     }
42
43     public JellyServletContext(JellyContext parent, ServletContext JavaDoc ctx) {
44         super(parent);
45         this.ctx = ctx;
46     }
47
48     /**
49      * Allow access of relative URIs when performing &lt;j:include&gt;.
50      * @param s
51      * @return
52      * @throws MalformedURLException
53      */

54     public URL JavaDoc getResource(String JavaDoc s) throws MalformedURLException JavaDoc {
55         return ctx.getResource(s);
56     }
57
58     /**
59      * Allow access of relative URIs when performing &lt;j:include&gt;.
60      * @param s
61      * @return
62      */

63     public InputStream JavaDoc getResourceAsStream(String JavaDoc s) {
64         return ctx.getResourceAsStream(s);
65     }
66
67     protected JellyContext createChildContext()
68     {
69         return new JellyServletContext(this, ctx);
70     }
71 }
72
Popular Tags