Return-Path: Mailing-List: contact tomcat-user-help@jakarta.apache.org; run by ezmlm Delivered-To: mailing list tomcat-user@jakarta.apache.org Received: (qmail 60766 invoked from network); 16 Jul 2000 02:38:06 -0000 Received: from lukla.sun.com (192.18.98.31) by locus.apache.org with SMTP; 16 Jul 2000 02:38:06 -0000 Received: from eastmail1.East.Sun.COM ([129.148.1.240]) by lukla.Sun.COM (8.9.3+Sun/8.9.3) with ESMTP id UAA27820 for ; Sat, 15 Jul 2000 20:38:06 -0600 (MDT) Received: from swanaba.east (swanaba.East.Sun.COM [129.148.162.54]) by eastmail1.East.Sun.COM (8.9.3+Sun/8.9.3/ENSMAIL,v1.7) with ESMTP id WAA12133 for ; Sat, 15 Jul 2000 22:38:05 -0400 (EDT) Received: from eng.sun.com (swantty.East.Sun.COM [129.148.162.52]) by swanaba.east (8.8.8+Sun/8.8.8) with ESMTP id WAA21197 for ; Sat, 15 Jul 2000 22:37:15 -0400 (EDT) Message-ID: <39711FF6.BEABD9B@eng.sun.com> Date: Sat, 15 Jul 2000 19:37:42 -0700 From: "Craig R. McClanahan" X-Mailer: Mozilla 4.72 [en]C-CCK-MCD {Sony} (Win98; U) X-Accept-Language: en MIME-Version: 1.0 To: tomcat-user@jakarta.apache.org Subject: Re: Mapping "/" and *only* "/" References: <20000716042001.A989@prometheus> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Peter Schuller wrote: > Hello, > > What is the correct procedure for mapping "/" (only "/") to a servlet? There is no mechanism to do this with . However, if you are trying to emulate the way that a web server will serve an "index.html" file to someone who asks for the directory itself, you can use the to identify the names of welcome files -- typically something like index.jsp -- that is displayed for this purpose. I haven't ever tried this with a servlet, but it ought to work. > With > the following servlet mapping, *all* requests are mapped to the servlet, and > I don't know why (since "/*" does that too; why does "/" do the same?): > The "/*" and "/" mappings do not quite do the same thing. The key issue is the order in which Tomcat, or any servlet container conforming to servlet 2.2, will try to match your request to a servlet based on the mappings: 1) Exact match 2) Longest prefix match against a pattern that ends in "/*" 3) Extension match (like *.jsp to the JSP servlet) 4) Default servlet (mapped to "/"). As you can see, the "default servlet" mapping is only used if no other servlet mapping matches. If you use a "/*" pattern, that will match everything (except for exact matches) so that any extension matching you want to do won't happen, because the "/*" match happens earlier in the priority order. > > > > fileviewer > > > / > > > In fact, the "default servlet" in Tomcat 3.1 is the servlet that serves static resources, which it defines as "anything for which no other servlet or JSP page matched." > > Thanks! > > -- > / Peter Schuller, InfiDyne Technologies HB > Craig McClanahan