tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeffrey Janner <Jeffrey.Jan...@PolyDyne.com>
Subject RE: Question on servlet determination
Date Wed, 24 Apr 2013 17:50:29 GMT
> -----Original Message-----
> From: Christopher Schultz [mailto:chris@christopherschultz.net]
> Sent: Wednesday, April 24, 2013 12:20 PM
> To: Tomcat Users List
> Subject: Re: Question on servlet determination
> 
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA256
> 
> Jeff,
> 
> On 4/23/13 5:45 PM, Jeffrey Janner wrote:
> >> -----Original Message----- From: Propes, Barry L
> >> [mailto:barry.l.propes@citi.com] Sent: Tuesday, April 23, 2013
> >> 4:34 PM To: 'Tomcat Users List' Subject: RE: Question on servlet
> >> determination
> >>
> >> I'm tempted to say no.
> >>
> >> Because you might be adding a "/" in front of your servlet mapping.
> >>
> >> In other words, changing the path of the folder slightly, with a
> >> different relative path.
> >>
> >
> > I went back and read the servlet spec for 2.5, and according to it,
> > Tomcat should be redirecting the URI ending "/Servlet2" to
> > "/Servlet2/" and then applying welcome files (I do have some defined,
> > just didn't include it below).  Amazingly, this appears to be what
> > happens.  However, if the ending "/" already exists, it doesn't just
> > go looking for welcome files.
> 
> If you have a servlet mapped to /Servlet1 (and /Servlet2), why should
> there be any redirecting at all? That should only happen if the
> DefaultServlet is handling the request and /Servlet1 refers to a
> directory (or something that looks like one).
> 
> - -chris

I was specifically using the terminology in the 2.5 spec.  To quote from page 72, the section
on Welcome Files:

Consider a Web application where:
• The deployment descriptor lists the following welcome files.
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
• The static content in the WAR is as follows
/foo/index.html
/foo/default.jsp
/foo/orderform.html
/foo/home.gif
/catalog/default.jsp
/catalog/products/shop.jsp
/catalog/products/register.jsp
• A request URI of /foo will be redirected to a URI of /foo/.
• A request URI of /foo/ will be returned as /foo/index.html.
• A request URI of /catalog will be redirected to a URI of /catalog/.
• A request URI of /catalog/ will be returned as /catalog/default.jsp.
• A request URI of /catalog/index.html will cause a 404 not found
• A request URI of /catalog/products will be redirected to a URI of /
catalog/products/.
• A request URI of /catalog/products/ will be passed to the “default” servlet,
if any. If no “default” servlet is mapped, the request may cause a 404 not
found, may cause a directory listing including shop.jsp and register.jsp, or
may cause other behavior defined by the container. See Section SRV.11.2,
“Specification of Mappings” for the definition of “default” servlet.

But then, I could have been interpreting that incorrectly, since I think it's referring to
requests into directories, not Servlets.

The more I think about it, the more I'm sure it's our code.  There are no directories that
match the servlet names.  Tomcat is correctly matching the servlet name, and passing the rest
of the request string to the servlet, null in the first case, and "/" in the second. Our code
assumes a null string means put up a specific page but doesn't know what to do with a "/"
(have not researched, but probable).  It's not really relying on the welcome-list at all.
That makes even more sense when you understand that both servlets have the same document base
(the Web directory), and both welcome files are in that directory, yet each servlet manages
to put up the servlet-specific welcome file.

Does that start to make sense, Chris?
Jeff
Mime
View raw message