You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Hans Bergsten <ha...@gefionsoftware.com> on 2000/03/07 20:16:32 UTC

Replacing default servlet in 3.1 Beta RC 1

Two things:

1) It's no longer possible to replace the default servlet with your own
   in Tomcat 3.1 Beta RC 1. I'm trying this with a new context, using
   the following mappings in web.xml:

     <web-app>
       <servlet>
         <servlet-name>
            snoop
         </servlet-name>
         <servlet-class>
            SnoopServlet
         </servlet-class>
       </servlet>
       <servlet-mapping>
         <servlet-name>
            snoop
         </servlet-name>
         <url-pattern>
            /
         </url-pattern>
       </servlet-mapping>
     </web-app>

   It used to work in a previous version. (I also tried with "/*", without success,
   but I believe "/" is the correct mapping for the default servlet).

2) In an older version, where this works, the paths returned from getServletPath() 
   and getPathInfo() seem to be incorrect. For instance, with a context path "/grx", 
   the URL http://localhost:port/grx/test.cmp gives the following results:

     getRequestURI() returns "/grx/test.cmp"
     getPathInfo() returns "/test.cmp"
     getServletPath() returns ""

   The Servlet 2.2 spec says:

     Servlet Path: The path section that directly corresponds to the mapping
     which activated this request. This path starts with a '/' character.
     Path Info: The part the request path that is not part of the Context Path or 
     the Servlet Path.

   My interpretation of this is that when the default mapping is used, the
   whole path is used for mapping and the result should therefore be

     getRequestURI() returns "/grx/test.cmp"
     getPathInfo() returns ""
     getServletPath() returns "/test.cmp"

  If you don't agree that this is a bug (rather different interpretations of the
  spec), maybe Danny Coward can clarify.

Hans
-- 
Hans Bergsten		hans@gefionsoftware.com
Gefion Software		http://www.gefionsoftware.com