DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUGĀ· RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT <http://issues.apache.org/bugzilla/show_bug.cgi?id=39496>. ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED ANDĀ· INSERTED IN THE BUG DATABASE.
http://issues.apache.org/bugzilla/show_bug.cgi?id=39496 Summary: Servlet mapping fails for subdirectory requests when subdirectory exists Product: Tomcat 5 Version: 5.5.17 Platform: PC OS/Version: All Status: NEW Severity: major Priority: P2 Component: Unknown AssignedTo: tomcat-dev@jakarta.apache.org ReportedBy: [EMAIL PROTECTED] I believe I have found a bug in servlet mapping in recent versions of Tomcat. The circumstances where this bug can be seen are quite convoluted but not uncommon: * A servlet mapping has been set up that matches requests for 'virtual' pages in the root and any subdirectory * A Host element matching a domain name has been set up and mapped to the webapp folder * The user browses to a 'virtual' file in a subdirectory, via the domain name * The subdirectory exists on the file system Under these circumstances, Tomcat 5.5.16 and 5.5.17 return a 404 error when the servlet should have handled the request. Steps to reproduce: 1. Create a hosts file entry to point a domain such as www.testdomain.com at the local machine. 2. Download and unzip the binary distribution apache-tomcat-5.5.17.zip 3. Add the following Host entry after the default localhost one in conf/server.xml <Host name="www.testdomain.com" debug="0" appBase="webapps\test" unpackWARs="true" autoDeploy="true"> <Context path="" docBase="" debug="0"/> </Host> 4. Create a folder in webapps named "test". Also create "test/subdir", "test/WEB-INF" and "test/WEB-INF/classes" 5. Add the following web.xml to WEB-INF. <?xml version="1.0" ?> <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd";> <web-app> <servlet> <servlet-name>test</servlet-name> <servlet-class>TestServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>test</servlet-name> <url-pattern>*.ser</url-pattern> </servlet-mapping> </web-app> 6. Compile this code and put it in the classes folder. import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; public class TestServlet extends HttpServlet { protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.getOutputStream().write("Servlet responded".getBytes()); } } 7. Start Tomcat with startup.bat. 8. Browse to the following URLs. http://localhost:8080/test/page.ser - OK http://localhost:8080/test/subdir/page.ser - OK http://localhost:8080/test/subdir2/page.ser - OK http://www.testdomain.com:8080/page.ser - OK http://www.testdomain.com:8080/subdir/page.ser - 404 http://www.testdomain.com:8080/subdir2/page.ser - OK I have tested 5.5.17 Windows and Linux binary distributions, and 5.5.16 under Windows, which all fail. 5.5.12, 5.0.30 and 4.1.31 successfully return all the above requests. I couldn't find 5.5.13-15 to test. -- Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are the assignee for the bug, or are watching the assignee. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]