You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by bu...@apache.org on 2003/02/12 09:37:52 UTC
DO NOT REPLY [Bug 16983] New: -
ServletContext.getContext(String) cannot return other contexts when called from root context.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=16983>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND
INSERTED IN THE BUG DATABASE.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=16983
ServletContext.getContext(String) cannot return other contexts when called from root context.
Summary: ServletContext.getContext(String) cannot return other
contexts when called from root context.
Product: Tomcat 4
Version: 4.1.18
Platform: All
OS/Version: All
Status: NEW
Severity: Major
Priority: Other
Component: Catalina
AssignedTo: tomcat-dev@jakarta.apache.org
ReportedBy: tobias@telenorlink.se
I believe the problem lies in the implementation of getContext(String)
in the class org.apache.catalina.core.ApplicationContext. I studied the
source and traced the problem to the following lines (starting at line 442):
String contextPath = context.getPath();
if (!contextPath.endsWith("/"))
contextPath = contextPath + "/";
if ((contextPath.length() > 0) && (uri.startsWith(contextPath))) {
return (this);
}
If the contextPath is "" (root), the above code will always return the
current context (since contextPath.length() > 0 will always be true).
A fix could be to replace the last if-statement with, for instance, the
following:
if ( ((contextPath.length() > 1) && (uri.startsWith(contextPath))) ||
contextPath.equals(uri) ) {
return (contextPath);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org