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 2002/08/20 17:20:14 UTC
DO NOT REPLY [Bug 11865] New: -
forward from root context always fails
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=11865>.
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=11865
forward from root context always fails
Summary: forward from root context always fails
Product: Tomcat 4
Version: 4.0.4 Final
Platform: Other
OS/Version: Other
Status: NEW
Severity: Normal
Priority: Other
Component: Catalina
AssignedTo: tomcat-dev@jakarta.apache.org
ReportedBy: hmm_@yoyomail.com
Attempting to forward from the root context to another context always fails
Here are the steps to replicate this problem:
1. Modify server.xml by adding the following:
<Context path="" docBase="ROOT" debug="0" crossContext="true"/>
<Context path="/context1" docBase="context1" debug="0" crossContext="true"/>
<Context path="/context2" docBase="context2" debug="0" crossContext="true"/>
2. Create the following jsp files:
/index.jsp and /context1/context1.jsp:
<%
getServletContext().getContext("/context2").getRequestDispatcher
("/context2.jsp").forward(request, response);
%>
/context2/context2.jsp:
This is context2.jsp
3. Try to access http://localhost:8080/context1/context1.jsp and notice that
this successfully forwards to /context2/context2.jsp
4. Try to access http://localhost:8080 or http://localhost:8080/index.jsp and
notice that this fails even though /index.jsp contains the same code
as /context1/context1.jsp
I believe (although I have not tested this) that the error lies in the
file /catalina/src/share/org/apache/catalina/core/ApplicationContext.java lines
440-448:
440
441 // Return the current context if requested
442 String contextPath = context.getPath();
443 remm 1.37 if (!contextPath.endsWith("/"))
444 contextPath = contextPath + "/";
445 if ((contextPath.length() > 0) && (uri.startsWith
(contextPath))) {
446 pier 1.29 return (this);
447 }
448
It seems like the above code will always return the current context of / when
forwarding from / since all uri's start with /
I believe this may have been working in version 1.36 of the file
ApplicationContext.java but stopped working in version 1.37 (the test used to
be uri.equals instead of uri.startsWith).
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>