André Warnier:

> It appears anyway that my previous attempted logic was quite wrong.
> But I still find the spec quite confusing.  There is some kind of 
> mixture between "servlet" and "web application" that is not very clear, 
> at least to me.
> 
> As I understand it now, there are 2 steps :
> 1) the appropriate webapp (not servlet) is located using the path, not 
> the <url-pattern>
> 2) the appropriate servlet *within* the webapp is selected based on the 
> <url-pattern>

Yes.
Example: given the URL http://<servername>/foo/bar/baz/, the Container
looks at /foo/bar/baz/ to find out which webapp should handle the request.
- If there's a webapp with the context path /foo/bar/baz, that's the one
to handle the request and the path for the servlet mapping is "/".
- If there's a webapp with the context path /foo/bar, that's the one to
handle the request and the path for the servlet mapping is "/baz/".
- If there's a webapp with the context path /foo, that's the one to
handle the request and the path for the servlet mapping is "/bar/baz/".
- If neither of the above is true, the webapp with the context path ""
(the default webapp, ROOT in Tomcat) is the one to handle the request
and the path for the servlet mapping is "/foo/bar/baz/".

> and
> 3) .. each webapp has a "default servlet", to which things get mapped 
> when no other <url-pattern> of this webapp matches

Essentially, yes. You could comment the Default Servlet and it's mapping
in ${catalina.base}/conf/web.xml, though.

> 4) the ROOT webapp matches the path "/", not the <url-pattern> /

The default webapp (named ROOT in Tomcat) matches the path "". Apart
from that, what you said in 1) is true for all webapps, including the
default one.

> Is the above correct ?
> 
> The confusing part for me may also be due to my misunderstanding.
> I view this as follows :
> - a "web application" is "the whole thing" that one finds below 
> (tomcat_dir)/webapps/xyz for example (including its static pages, 
> WEB-INF/web.xml, its servlets etc..)
> - this webapp can consist of one or more servlets, each with its set of 
> <url-pattern>'s that it handles
> 
> Not so ?

No, correct.

> And if so, then I find the examples in table "SRV.11.2.2 Example Mapping 
> Set" quite confusing, since paths like
> /foo
> /bar
> /catalog
> would tend to imply different webapps, rather than different servlets 
> inside of one webapp, no ?

No. These examples talk about the mappings *inside* a webapp, i. e. what
can be used as a value for <url-mapping>.
In other words: the part of the request URL which is used to determine
the webapp to handle the request is already removed.

Take this trivial JSP and deploy it to different contexts/webapps. Maybe
the output will make things clearer:

<html>
<body>
<table>
<tr><td>RequestURL</td><td><%= request.getRequestURL() %></td></tr>
<tr><td>RequestURI</td><td><%= request.getRequestURI() %></td></tr>
<tr><td>ContextPath</td><td><%= request.getContextPath() %></td></tr>
<tr><td>ServletPath</td><td><%= request.getServletPath() %></td></tr>
</table>
</body>
</html>

Regards
  mks

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to