当前位置: 首页>>代码示例>>Java>>正文


Java Context.getServletContext方法代码示例

本文整理汇总了Java中org.apache.catalina.Context.getServletContext方法的典型用法代码示例。如果您正苦于以下问题:Java Context.getServletContext方法的具体用法?Java Context.getServletContext怎么用?Java Context.getServletContext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.catalina.Context的用法示例。


在下文中一共展示了Context.getServletContext方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: WebappServiceLoader

import org.apache.catalina.Context; //导入方法依赖的package包/类
/**
 * Construct a loader to load services from a ServletContext.
 *
 * @param context the context to use
 */
public WebappServiceLoader(Context context) {
    this.context = context;
    this.servletContext = context.getServletContext();
    String containerSciFilter = context.getContainerSciFilter();
    if (containerSciFilter != null && containerSciFilter.length() > 0) {
        containerSciFilterPattern = Pattern.compile(containerSciFilter);
    } else {
        containerSciFilterPattern = null;
    }
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:16,代码来源:WebappServiceLoader.java

示例2: getServletContext

import org.apache.catalina.Context; //导入方法依赖的package包/类
/**
 * Return the ServletContext to which this session belongs.
 */
@Override
public ServletContext getServletContext() {
    if (manager == null) {
        return null;
    }
    Context context = (Context) manager.getContainer();
    return context.getServletContext();
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:12,代码来源:StandardSession.java

示例3: testBug54240

import org.apache.catalina.Context; //导入方法依赖的package包/类
@Test
public void testBug54240() throws Exception {
    Tomcat tomcat = getTomcatInstance();

    File appDir = new File("test/webapp-3.0");
    Context ctx = tomcat.addWebapp(null, "/test", appDir.getAbsolutePath());
    tomcat.start();

    ServletContext context = ctx.getServletContext();

    TagPluginManager manager = new TagPluginManager(context);

    Node.Nodes nodes = new Node.Nodes();
    Node.CustomTag c = new Node.CustomTag("test:ATag", "test", "ATag",
            "http://tomcat.apache.org/jasper", null, null, null, null, null,
            new TagFileInfo("ATag", "http://tomcat.apache.org/jasper",
                    tagInfo));
    c.setTagHandlerClass(TesterTag.class);
    nodes.add(c);
    manager.apply(nodes, null, null);

    Node n = nodes.getNode(0);
    Assert.assertNotNull(n);
    Assert.assertTrue(n instanceof Node.CustomTag);

    Node.CustomTag t = (Node.CustomTag)n;
    Assert.assertNotNull(t.getAtSTag());

    Node.Nodes sTag = c.getAtSTag();
    Node scriptlet = sTag.getNode(0);
    Assert.assertNotNull(scriptlet);
    Assert.assertTrue(scriptlet instanceof Node.Scriptlet);
    Node.Scriptlet s = (Node.Scriptlet)scriptlet;
    Assert.assertEquals("//Just a comment", s.getText());
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:36,代码来源:TestTagPluginManager.java

示例4: getServletContext

import org.apache.catalina.Context; //导入方法依赖的package包/类
/**
 * Return the ServletContext to which this session belongs.
 */
public ServletContext getServletContext() {

    if (manager == null)
        return (null);
    Context context = (Context) manager.getContainer();
    if (context == null)
        return (null);
    else
        return (context.getServletContext());

}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:15,代码来源:StandardSession.java

示例5: getContext

import org.apache.catalina.Context; //导入方法依赖的package包/类
/**
 * Return a <code>ServletContext</code> object that corresponds to a
 * specified URI on the server.  This method allows servlets to gain
 * access to the context for various parts of the server, and as needed
 * obtain <code>RequestDispatcher</code> objects or resources from the
 * context.  The given path must be absolute (beginning with a "/"),
 * and is interpreted based on our virtual host's document root.
 *
 * @param uri Absolute URI of a resource on the server
 */
public ServletContext getContext(String uri) {

    // Validate the format of the specified argument
    if ((uri == null) || (!uri.startsWith("/")))
        return (null);

    // Return the current context if requested
    String contextPath = context.getPath();
    if (!contextPath.endsWith("/"))
        contextPath = contextPath + "/";
    if ((contextPath.length() > 0) && (uri.startsWith(contextPath))) {
        return (this);
    }

    // Return other contexts only if allowed
    if (!context.getCrossContext())
        return (null);
    try {
        Host host = (Host) context.getParent();
        Context child = host.map(uri);
        if (child != null)
            return (child.getServletContext());
        else
            return (null);
    } catch (Throwable t) {
        return (null);
    }

}
 
开发者ID:c-rainstorm,项目名称:jerrydog,代码行数:40,代码来源:ApplicationContext.java

示例6: WebappServiceLoader

import org.apache.catalina.Context; //导入方法依赖的package包/类
/**
 * Construct a loader to load services from a ServletContext.
 *
 * @param context
 *            the context to use
 */
public WebappServiceLoader(Context context) {
	this.context = context;
	this.servletContext = context.getServletContext();
	String containerSciFilter = context.getContainerSciFilter();
	if (containerSciFilter != null && containerSciFilter.length() > 0) {
		containerSciFilterPattern = Pattern.compile(containerSciFilter);
	} else {
		containerSciFilterPattern = null;
	}
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:17,代码来源:WebappServiceLoader.java

示例7: getServletContext

import org.apache.catalina.Context; //导入方法依赖的package包/类
/**
 * Return the ServletContext to which this session belongs.
 */
@Override
public ServletContext getServletContext() {
	if (manager == null) {
		return null;
	}
	Context context = (Context) manager.getContainer();
	return context.getServletContext();
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:12,代码来源:StandardSession.java

示例8: testBug54239

import org.apache.catalina.Context; //导入方法依赖的package包/类
@Test
public void testBug54239() throws Exception {
    Tomcat tomcat = getTomcatInstance();

    File appDir = new File("test/webapp-3.0");
    Context ctx = tomcat.addWebapp(null, "/test", appDir.getAbsolutePath());
    tomcat.start();

    ServletContext context = ctx.getServletContext();

    ELInterpreter interpreter =
            ELInterpreterFactory.getELInterpreter(context);
    Assert.assertNotNull(interpreter);
    Assert.assertTrue(interpreter instanceof DefaultELInterpreter);

    context.removeAttribute(ELInterpreter.class.getName());

    context.setAttribute(ELInterpreter.class.getName(),
            SimpleELInterpreter.class.getName());
    interpreter = ELInterpreterFactory.getELInterpreter(context);
    Assert.assertNotNull(interpreter);
    Assert.assertTrue(interpreter instanceof SimpleELInterpreter);

    context.removeAttribute(ELInterpreter.class.getName());

    SimpleELInterpreter simpleInterpreter = new SimpleELInterpreter();
    context.setAttribute(ELInterpreter.class.getName(), simpleInterpreter);
    interpreter = ELInterpreterFactory.getELInterpreter(context);
    Assert.assertNotNull(interpreter);
    Assert.assertTrue(interpreter instanceof SimpleELInterpreter);
    Assert.assertTrue(interpreter == simpleInterpreter);

    context.removeAttribute(ELInterpreter.class.getName());

    ctx.stop();
    ctx.addApplicationListener(Bug54239Listener.class.getName());
    ctx.start();

    interpreter = ELInterpreterFactory.getELInterpreter(ctx.getServletContext());
    Assert.assertNotNull(interpreter);
    Assert.assertTrue(interpreter instanceof SimpleELInterpreter);
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:43,代码来源:TestELInterpreterFactory.java


注:本文中的org.apache.catalina.Context.getServletContext方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。