本文整理匯總了Java中javax.servlet.ServletContext.getContext方法的典型用法代碼示例。如果您正苦於以下問題:Java ServletContext.getContext方法的具體用法?Java ServletContext.getContext怎麽用?Java ServletContext.getContext使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.servlet.ServletContext
的用法示例。
在下文中一共展示了ServletContext.getContext方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getServletContextAndPathFromVirtualPath
import javax.servlet.ServletContext; //導入方法依賴的package包/類
protected ServletContextAndPath getServletContextAndPathFromVirtualPath( String virtualPath ) throws IOException {
ServletContext servletContext = servlet.getServletContext();
String path = null;
if ( !virtualPath.startsWith("/") && !virtualPath.startsWith("\\") ) {
path = getAbsolutePath( virtualPath );
} else {
String normalized = SSIServletRequestUtil.normalize( virtualPath );
if ( isVirtualWebappRelative ) {
path = normalized;
} else {
servletContext = servletContext.getContext( normalized );
if ( servletContext == null ) {
throw new IOException("Couldn't get context for path: " + normalized );
}
//If it's the root context, then there is no context element to remove, ie:
// '/file1.shtml' vs '/appName1/file1.shtml'
if ( !isRootContext( servletContext ) ) {
path = getPathWithoutContext( normalized );
if ( path == null ) {
throw new IOException("Couldn't remove context from path: " + normalized );
}
} else {
path = normalized;
}
}
}
return new ServletContextAndPath( servletContext, path );
}
示例2: isRootContext
import javax.servlet.ServletContext; //導入方法依賴的package包/類
protected boolean isRootContext(ServletContext servletContext) {
return servletContext == servletContext.getContext("/");
}
示例3: isRootContext
import javax.servlet.ServletContext; //導入方法依賴的package包/類
protected boolean isRootContext( ServletContext servletContext ) {
return servletContext == servletContext.getContext( "/" );
}
示例4: isRootContext
import javax.servlet.ServletContext; //導入方法依賴的package包/類
protected boolean isRootContext(ServletContext servletContext) {
return servletContext == servletContext.getContext("/");
}