當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。