tomcat共享多个web应用会话的实现方法(tomcat多个service)怎么可以错过

随心笔谈2年前发布 编辑
150 0
🌐 经济型:买域名、轻量云服务器、用途:游戏 网站等 《腾讯云》特点:特价机便宜 适合初学者用 点我优惠购买
🚀 拓展型:买域名、轻量云服务器、用途:游戏 网站等 《阿里云》特点:中档服务器便宜 域名备案事多 点我优惠购买
🛡️ 稳定型:买域名、轻量云服务器、用途:游戏 网站等 《西部数码》 特点:比上两家略贵但是稳定性超好事也少 点我优惠购买


public ServletContext getContext(String uri) {

// Validate the format of the specified argument
if (uri==null || !uri.startsWith(“/”)) {
return null;
}

Context child=null;
try {
// Look for an exact match
Container host=context.getParent();
child=(Context) host.findChild(uri);

// Non-running contexts should be ignored.
if (child !=null && !child.getState().isAvailable()) {
child=null;
}

// Remove any version information and use the mapper
if (child==null) {
int i=uri.indexOf(“##”);
if (i > -1) {
uri=uri.substring(0, i);
}
// Note: This could be more efficient with a dedicated Mapper
// method but such an implementation would require some
// refactoring of the Mapper to avoid copy/paste of
// existing code.
MessageBytes hostMB=MessageBytes.newInstance();
hostMB.setString(host.getName());

MessageBytes pathMB=MessageBytes.newInstance();
pathMB.setString(uri);

MappingData mappingData=new MappingData();
((Engine) host.getParent()).getService().findConnectors()[0].getMapper().map(
hostMB, pathMB, null, mappingData);
child=(Context) mappingData.context;
}
} catch (Throwable t) {
ExceptionUtils.handleThrowable(t);
return null;
}

if (child==null) {
return null;
}

if (context.getCrossContext()) {
// If crossContext is enabled, can always return the context
return child.getServletContext();
} else if (child==context) {
// Can still return the current context
return context.getServletContext();
} else {
// Nothing to return
return null;
}
}

© 版权声明

相关文章