Summary: | getContext() fails for xml-specified contexts | ||
---|---|---|---|
Product: | Tomcat 5 | Reporter: | Juergen Weber <juergen> |
Component: | Catalina | Assignee: | Tomcat Developers Mailing List <dev> |
Status: | CLOSED INVALID | ||
Severity: | normal | ||
Priority: | P3 | ||
Version: | 5.0.19 | ||
Target Milestone: | --- | ||
Hardware: | Other | ||
OS: | All |
Description
Juergen Weber
2004-03-24 23:10:55 UTC
Obviously not. I get C:\java\jakarta-tomcat-5.0.19\webapps\ROOT\ C:\java\jakarta-tomcat-5.0.19\webapps\ROOT\ C:\java\jakarta-tomcat-5.0.19\webapps\..\server\webapps\manager\ for <% javax.servlet.ServletContext context; context = pageContext.getServletContext().getContext("/manager/"); if (null!= context) { out.print(context.getRealPath("/")); } out.print("<p>"); context = pageContext.getServletContext().getContext("/manager/manager-howto.html"); if (null!= context) { out.print(context.getRealPath("/")); } out.print("<p>"); context = pageContext.getServletContext().getContext("/manager"); if (null!= context) { out.print(context.getRealPath("/")); } %> Note that the scriptlet must be run from a context with crossContext="true". The output should be three times the third output line, corresponding to http://jakarta.apache.org/tomcat/tomcat-5.0-doc/servletapi/javax/servlet/ServletContext.html#getContext(java.lang.String) I did test it. Thanks for not wasting my time. For those that also run into this bug, it was fixed after the release of jakarta-tomcat-5.0.19. In ApplicationContextFacade.java there was while (true) { child = (Context) host.findChild(mapuri); if (context != null) break; int slash = mapuri.lastIndexOf('/'); if (slash < 0) break; mapuri = mapuri.substring(0, slash); } The if (context != null) was always true, it is now if (child != null). |