本文整理匯總了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;
}
}
示例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();
}
示例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());
}
示例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());
}
示例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);
}
}
示例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;
}
}
示例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();
}
示例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);
}