RE: Tomcat mapping of URLs -> servlets

2008-12-03 Thread Caldarale, Charles R
> From: André Warnier [mailto:[EMAIL PROTECTED]
> Subject: Re: Tomcat mapping of URLs -> servlets
>
> Except if there was, for /foo/bar, an appropriate  element,
> inside a foo#bar.xml file, itself located under
> (tomcat_base)/conf/Catalina/(hostname)/

Or an [appBase]/foo#bar directory, or an [appBase]/foo#bar.war file (current 
Tomcat levels only).

> But for a beginner it is really hard to get a grip.

As with many things, you sometimes have to know 90% of the answer before you 
can ask the question.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY 
MATERIAL and is thus for use only by the intended recipient. If you received 
this in error, please contact the sender and delete the e-mail and its 
attachments from all computers.

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



Re: Tomcat mapping of URLs -> servlets

2008-12-03 Thread Mark Thomas
André Warnier wrote:
> Caldarale, Charles R wrote:
>>> From: André Warnier [mailto:[EMAIL PROTECTED]
>>> Subject: Re: Tomcat mapping of URLs -> servlets
>>>
>>> At deployment time thus (in my hypothetical case above when
>>> Tomcat starts and finds a such webapps top dir), does it
>>> recursively go through the webapp dirs and subdirs, to
>>> determine what is a webapp and what is not ?
>>
>> No, that's not necessary; only .war files and directories immediately
>> under a 's appBase along with any  elements with
>> non-redundant docBase attributes are webapps.
>>
> Ok, thanks.
> So, in my admittedly forced earlier example, only /foo would be
> recognised as a webapp, and even /foo/bar would not be.
> Except if there was, for /foo/bar, an appropriate  element,
> inside a foo#bar.xml file, itself located under
> (tomcat_base)/conf/Catalina/(hostname)/
> 
> Have I finally got it right ?

Almost ;)

As of 6.0.18 you can have foo#bar.war or a foo#bar directory in your host's
appBase and they will also be recognised as having a context path of /foo/bar

Mark


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



Re: Tomcat mapping of URLs -> servlets

2008-12-03 Thread André Warnier

Caldarale, Charles R wrote:

From: André Warnier [mailto:[EMAIL PROTECTED]
Subject: Re: Tomcat mapping of URLs -> servlets

At deployment time thus (in my hypothetical case above when
Tomcat starts and finds a such webapps top dir), does it
recursively go through the webapp dirs and subdirs, to
determine what is a webapp and what is not ?


No, that's not necessary; only .war files and directories immediately under a 
's appBase along with any  elements with non-redundant docBase 
attributes are webapps.


Ok, thanks.
So, in my admittedly forced earlier example, only /foo would be 
recognised as a webapp, and even /foo/bar would not be.
Except if there was, for /foo/bar, an appropriate  element, 
inside a foo#bar.xml file, itself located under 
(tomcat_base)/conf/Catalina/(hostname)/


Have I finally got it right ?
(Not quite sure about the foo#bar thing, but I think  remember reading 
that on this list)


You know, I think I am beginning to understand the problem with the 
documentation.  While the API is fairly hierarchical and lends itself to 
that kind of documentation structure, the configuration of Tomcat itself 
doesn't.  Each element seems to require as a pre-requisite the knowledge 
of many others, which makes it really hard to explain something in a 
simple and progressive fashion.
Maybe someone who has been involved for years with Tomcat, or who is 
involved in the design itself of Tomcat, sees this in a different way. 
But for a beginner it is really hard to get a grip.


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



RE: Tomcat mapping of URLs -> servlets

2008-12-03 Thread Caldarale, Charles R
> From: André Warnier [mailto:[EMAIL PROTECTED]
> Subject: Re: Tomcat mapping of URLs -> servlets
>
> At deployment time thus (in my hypothetical case above when
> Tomcat starts and finds a such webapps top dir), does it
> recursively go through the webapp dirs and subdirs, to
> determine what is a webapp and what is not ?

No, that's not necessary; only .war files and directories immediately under a 
's appBase along with any  elements with non-redundant docBase 
attributes are webapps.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY 
MATERIAL and is thus for use only by the intended recipient. If you received 
this in error, please contact the sender and delete the e-mail and its 
attachments from all computers.

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



Re: Tomcat mapping of URLs -> servlets

2008-12-03 Thread André Warnier

Mark Thomas wrote:

André Warnier wrote:

Mark Thomas wrote:

André Warnier wrote:

Then I guess I have (at least) 2 webapps : a "/foo" webapp, and a
"/foo/bar" webapp.

Now a request comes in with the url "/foo/bar/baz/various.jsp"

How does Tomcat determine that /foo/bar/baz is not itself a webapp, but
merely a sub-dir of webapp "/foo/bar" ?

The longest context path always wins. So in this case any request to
/foo/bar/... will always be handled by the /foo/bar webapp.


I guess I wasn't clear enough in my question.

What I meant to ask was : considering the apparent path of the URL is
"/foo/bar/baz/", how/why does Tomcat "give up" on the "/foo/bar/baz"
(potential) webapp path, and attribute this to the "/foo/bar" webapp.

Of course, you and me know that there is no webapp in "/foo/bar/baz",
but we're smart humans who can just see this at a glance.
But how Tomcat know ?
Because there is no WEB-INF there, right now when it checks ? or because
of something we did/did not tell him earlier ?


It maintains an internal list of deployed contexts (web apps) and their
associated paths so it knows there is no /foo/bar/baz webapp.

At the risk of heavily insisting, but it seems we've now moved the issue 
back to the webapp deployment time, but not really solved it.
At deployment time thus (in my hypothetical case above when Tomcat 
starts and finds a such webapps top dir), does it recursively go through 
the webapp dirs and subdirs, to determine what is a webapp and what is not ?


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



Re: [OT] Tomcat mapping of URLs -> servlets

2008-12-03 Thread André Warnier

Caldarale, Charles R wrote:

From: André Warnier [mailto:[EMAIL PROTECTED]
Subject: Re: Tomcat mapping of URLs -> servlets

I was using Firefox 2.0.0.15, on a Windows XP station.


Hmmm... I haven't used Firefox 2 in a very long time - not since Firefox 3 was 
in beta.


http___cds-esd.sun.com_ESD34_JSCDL_servlet_2.5-mrel2_servlet-2
_5-mrel2-spec.pdf_AuthParam=1228317193_d403854b71d795ea3a31917
ee8f68382&TicketId=nodzAVkWRHd5l%2BIvkk6ZUZmZdA%3D%3D&GroupNam
e=CDS&FilePath=_ESD34_JSCDL_servlet_2.5-mrel2_servlet-2_5-mrel
2-spec.pdf&File=servlet-2_5-mrel2-spec.pdf

and that is what it does not like.


I wouldn't either.  Again, using current versions of Firefox and Adobe Reader, 
the problem doesn't seem to exist.



Using the Firefox LiveHttpHeaders add-on, it is quite interesting to see 
what really happens when opening this document in the PDF plugin.
At any rate, there is no "Content-disposition:" header with a filename 
coming from the server.
So the filename above and its usage in the file..save dialog must be a 
function of the plugin, not the browser.
Maybe a more recent PDF plugin splits the above string at the "&File=" 
portion.




http://cds-esd.sun.com/ESD34/JSCDL/servlet/2.5-mrel2/servlet-2_5-mrel2-spec.pdf?AuthParam=1228318870_1110e1ea2590969b0c44bee9625ff3aa&TicketId=B%2Fw6nRqGSlxISRRFOlFflw7m&GroupName=CDS&FilePath=/ESD34/JSCDL/servlet/2.5-mrel2/servlet-2_5-mrel2-spec.pdf&File=servlet-2_5-mrel2-spec.pdf

GET 
/ESD34/JSCDL/servlet/2.5-mrel2/servlet-2_5-mrel2-spec.pdf?AuthParam=1228318870_1110e1ea2590969b0c44bee9625ff3aa&TicketId=B%2Fw6nRqGSlxISRRFOlFflw7m&GroupName=CDS&FilePath=/ESD34/JSCDL/servlet/2.5-mrel2/servlet-2_5-mrel2-spec.pdf&File=servlet-2_5-mrel2-spec.pdf 
HTTP/1.1

Host: cds-esd.sun.com
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.8.1.15) 
Gecko/20080623 Firefox/2.0.0.15
Accept: 
text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5

Accept-Language: en-gb,en;q=0.7,de-de;q=0.3
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Cookie: s_vi=[CS]v1|491096734D51-A02085E2721[CE]; s_cc=true; 
s_sq=%5B%5BB%5D%5D


HTTP/1.x 200 OK
Server: Apache
Etag: "57587018e35c367a072891456a862416:1189475510"
Last-Modified: Mon, 10 Sep 2007 23:49:29 GMT
Accept-Ranges: bytes
Content-Length: 2248516
Content-Type: application/pdf
Expires: Wed, 03 Dec 2008 15:39:11 GMT
Cache-Control: max-age=0, no-cache
Pragma: no-cache
Date: Wed, 03 Dec 2008 15:39:11 GMT
Connection: keep-alive


.. and after that a lot of "partial-content" byterange answers.
But also without filename.

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



RE: Tomcat mapping of URLs -> servlets

2008-12-03 Thread Caldarale, Charles R
> From: André Warnier [mailto:[EMAIL PROTECTED]
> Subject: Re: Tomcat mapping of URLs -> servlets
>
> I was using Firefox 2.0.0.15, on a Windows XP station.

Hmmm... I haven't used Firefox 2 in a very long time - not since Firefox 3 was 
in beta.

> http___cds-esd.sun.com_ESD34_JSCDL_servlet_2.5-mrel2_servlet-2
> _5-mrel2-spec.pdf_AuthParam=1228317193_d403854b71d795ea3a31917
> ee8f68382&TicketId=nodzAVkWRHd5l%2BIvkk6ZUZmZdA%3D%3D&GroupNam
> e=CDS&FilePath=_ESD34_JSCDL_servlet_2.5-mrel2_servlet-2_5-mrel
> 2-spec.pdf&File=servlet-2_5-mrel2-spec.pdf
>
> and that is what it does not like.

I wouldn't either.  Again, using current versions of Firefox and Adobe Reader, 
the problem doesn't seem to exist.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY 
MATERIAL and is thus for use only by the intended recipient. If you received 
this in error, please contact the sender and delete the e-mail and its 
attachments from all computers.

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



Re: Tomcat mapping of URLs -> servlets

2008-12-03 Thread Mark Thomas
André Warnier wrote:
> Mark Thomas wrote:
>> André Warnier wrote:
>>> Then I guess I have (at least) 2 webapps : a "/foo" webapp, and a
>>> "/foo/bar" webapp.
>>>
>>> Now a request comes in with the url "/foo/bar/baz/various.jsp"
>>>
>>> How does Tomcat determine that /foo/bar/baz is not itself a webapp, but
>>> merely a sub-dir of webapp "/foo/bar" ?
>>
>> The longest context path always wins. So in this case any request to
>> /foo/bar/... will always be handled by the /foo/bar webapp.
>>
> I guess I wasn't clear enough in my question.
> 
> What I meant to ask was : considering the apparent path of the URL is
> "/foo/bar/baz/", how/why does Tomcat "give up" on the "/foo/bar/baz"
> (potential) webapp path, and attribute this to the "/foo/bar" webapp.
> 
> Of course, you and me know that there is no webapp in "/foo/bar/baz",
> but we're smart humans who can just see this at a glance.
> But how Tomcat know ?
> Because there is no WEB-INF there, right now when it checks ? or because
> of something we did/did not tell him earlier ?

It maintains an internal list of deployed contexts (web apps) and their
associated paths so it knows there is no /foo/bar/baz webapp.

Mark



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



Re: Tomcat mapping of URLs -> servlets

2008-12-03 Thread André Warnier

Mark Thomas wrote:

André Warnier wrote:

Then I guess I have (at least) 2 webapps : a "/foo" webapp, and a
"/foo/bar" webapp.

Now a request comes in with the url "/foo/bar/baz/various.jsp"

How does Tomcat determine that /foo/bar/baz is not itself a webapp, but
merely a sub-dir of webapp "/foo/bar" ?


The longest context path always wins. So in this case any request to
/foo/bar/... will always be handled by the /foo/bar webapp.


I guess I wasn't clear enough in my question.

What I meant to ask was : considering the apparent path of the URL is 
"/foo/bar/baz/", how/why does Tomcat "give up" on the "/foo/bar/baz" 
(potential) webapp path, and attribute this to the "/foo/bar" webapp.


Of course, you and me know that there is no webapp in "/foo/bar/baz", 
but we're smart humans who can just see this at a glance.

But how Tomcat know ?
Because there is no WEB-INF there, right now when it checks ? or because 
of something we did/did not tell him earlier ?




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



Re: Tomcat mapping of URLs -> servlets

2008-12-03 Thread André Warnier

Caldarale, Charles R wrote:
[...]

Forgot to add :
mine is an Official Firefox, running on an Official Windows XP.
;-)


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



Re: Tomcat mapping of URLs -> servlets

2008-12-03 Thread André Warnier

Caldarale, Charles R wrote:

From: Caldarale, Charles R
Subject: RE: Tomcat mapping of URLs -> servlets

Note that the "servlet-2_5-mrel2-spec.pdf" button cannot be
right-clicked and processed with "Save As"


I was mistaken; you can do a right-click and "Save As", without any problems.  Were you 
on the correct page when you tried it?  The proper one is has the file name with a down arrow next 
to it, and a "Download Selected with Sun Download Manager" button below that.  All three 
methods (left click on the file name, right click on the file name, and the Download Manager) 
worked properly for me, with no invalid paths to edit.

Still a mystery why JCP keeps it so well hidden.


Just remember this, you gurus here, when you tell an OP to just go look 
at the specs..





I was using Firefox 2.0.0.15, on a Windows XP station.
I just clicked on the download link, let the document open in the 
browser's PDF plugin, then clicked on the "save a copy" diskette icon of 
the plugin.
It came up with the standard file dialog, on which I just clicked on the 
"Save" button.

That's when it popped up with an invalid path dialog.
The filename indeed in the file..save dialog was very very long, which I 
guess it didn't like.


In fact I just re-did this, with the same result.
The filename as shown in the file..save box is :

http___cds-esd.sun.com_ESD34_JSCDL_servlet_2.5-mrel2_servlet-2_5-mrel2-spec.pdf_AuthParam=1228317193_d403854b71d795ea3a31917ee8f68382&TicketId=nodzAVkWRHd5l%2BIvkk6ZUZmZdA%3D%3D&GroupName=CDS&FilePath=_ESD34_JSCDL_servlet_2.5-mrel2_servlet-2_5-mrel2-spec.pdf&File=servlet-2_5-mrel2-spec.pdf

and that is what it does not like.


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



Re: Tomcat mapping of URLs -> servlets

2008-12-03 Thread Mark Thomas
André Warnier wrote:
> Then I guess I have (at least) 2 webapps : a "/foo" webapp, and a
> "/foo/bar" webapp.
> 
> Now a request comes in with the url "/foo/bar/baz/various.jsp"
> 
> How does Tomcat determine that /foo/bar/baz is not itself a webapp, but
> merely a sub-dir of webapp "/foo/bar" ?

The longest context path always wins. So in this case any request to
/foo/bar/... will always be handled by the /foo/bar webapp.

Mark


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



Re: Tomcat mapping of URLs -> servlets

2008-12-03 Thread André Warnier

Markus Schönhaber wrote:

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 
2) the appropriate servlet *within* the webapp is selected based on the 



Yes.
Example: given the URL http:///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  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  /


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 
'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 .
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:




RequestURL<%= request.getRequestURL() %>
RequestURI<%= request.getRequestURI() %>
ContextPath<%= request.getContextPath() %>
ServletPath<%= request.getServletPath() %>





Thanks.

Now still one more question, based upon what you wrote above :
> - 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 "/".

Not that I would necessarily do this, but assuming that I create the 
following file structure :


(tomcat_dir)/webapps
   /foo
  various.jsp
  WEB-INF
 web.xml
  /bar
 various.jsp
 WEB-INF
web.xml
 /baz
various.jsp

and I start Tomcat.

Then I guess I have (at least) 2 webapps : a "/foo" webapp, and a 
"/foo/bar" webapp.


Now a request comes in with the url "/foo/bar/baz/various.jsp"

How does Tomcat determine that /foo/bar/baz is not itself a webapp, but 
merely a sub-dir of webapp "/foo/bar" ?

Or does it complain somewhere along the way ?

That may not be the right way to ask the question, so to put this 
another way : when Tomcat starts, does it recurse into each webapp dir 
to see if there is (for instance) another WEB-INF subdir hidden deeper 
there ?  Or does this information come from somewhere else ?






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



RE: Tomcat mapping of URLs -> servlets

2008-12-03 Thread Caldarale, Charles R
> From: Caldarale, Charles R
> Subject: RE: Tomcat mapping of URLs -> servlets
>
> Note that the "servlet-2_5-mrel2-spec.pdf" button cannot be
> right-clicked and processed with "Save As"

I was mistaken; you can do a right-click and "Save As", without any problems.  
Were you on the correct page when you tried it?  The proper one is has the file 
name with a down arrow next to it, and a "Download Selected with Sun Download 
Manager" button below that.  All three methods (left click on the file name, 
right click on the file name, and the Download Manager) worked properly for me, 
with no invalid paths to edit.

Still a mystery why JCP keeps it so well hidden.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY 
MATERIAL and is thus for use only by the intended recipient. If you received 
this in error, please contact the sender and delete the e-mail and its 
attachments from all computers.

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



RE: Tomcat mapping of URLs -> servlets

2008-12-03 Thread Caldarale, Charles R
> From: André Warnier [mailto:[EMAIL PROTECTED]
> Subject: Re: Tomcat mapping of URLs -> servlets
>
> Even when you get there though, it is still difficult to download this
> thing. The proposed filename is not a valid path and must be changed..

What browser and platform are you using?  (I'm asking because I have no 
problems with viewing the PDF and saving it.)  Note that the 
"servlet-2_5-mrel2-spec.pdf" button cannot be right-clicked and processed with 
"Save As"; you must use a left-click, let Adobe Reader open, and save from 
there.

The only problem with the file name is that the document is really MR6, not MR2.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY 
MATERIAL and is thus for use only by the intended recipient. If you received 
this in error, please contact the sender and delete the e-mail and its 
attachments from all computers.

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



Re: Tomcat mapping of URLs -> servlets

2008-12-03 Thread Markus Schönhaber
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 
> 2) the appropriate servlet *within* the webapp is selected based on the 
> 

Yes.
Example: given the URL http:///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  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  /

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 
> '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 .
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:




RequestURL<%= request.getRequestURL() %>
RequestURI<%= request.getRequestURI() %>
ContextPath<%= request.getContextPath() %>
ServletPath<%= request.getServletPath() %>




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]



Re: Tomcat mapping of URLs -> servlets

2008-12-03 Thread André Warnier

Markus Schönhaber wrote:

André Warnier:

I have tried to download and find this in the Servlet 2.5 Specification, 
but I seem to get a series of html pages describing the API, without 
telling me much about the general principles.


Yep, for some reason unknown to me it's unnecessarily difficult to find
the PDF with the 2.5 spec. Go here
http://jcp.org/en/jsr/detail?id=154
and select the topmost "Download page", i. e. the one for "Maintenance
release 2" and you're just a few clicks away from downloading the PDF.

Thanks, that works.
Even when you get there though, it is still difficult to download this 
thing. The proposed filename is not a valid path and must be changed..




Starting on p. 87 the section "Mapping Requests to Servlets" will
probably answer your questions.


Kind of.
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 
2) the appropriate servlet *within* the webapp is selected based on the 


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

4) the ROOT webapp matches the path "/", not the  /

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 
's that it handles


Not so ?

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 ?



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



Re: Tomcat mapping of URLs -> servlets

2008-12-03 Thread Markus Schönhaber
André Warnier:

> I have tried to download and find this in the Servlet 2.5 Specification, 
> but I seem to get a series of html pages describing the API, without 
> telling me much about the general principles.

Yep, for some reason unknown to me it's unnecessarily difficult to find
the PDF with the 2.5 spec. Go here
http://jcp.org/en/jsr/detail?id=154
and select the topmost "Download page", i. e. the one for "Maintenance
release 2" and you're just a few clicks away from downloading the PDF.

Starting on p. 87 the section "Mapping Requests to Servlets" will
probably answer your questions.

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]



Tomcat mapping of URLs -> servlets

2008-12-03 Thread André Warnier

Hi.

This is a beginner-like question.
I have tried to download and find this in the Servlet 2.5 Specification, 
but I seem to get a series of html pages describing the API, without 
telling me much about the general principles.


So just in case this is not nicely explained in English in the spec :

How does a servlet container like Tomcat map a request URI to any 
particular webapp ?


I mean, suppose we have 3 webapps with each a  section, 
in which each time there are several  tags.


I am not talking here about the strict interpretation of these 
 tags (although there is a question about why the servlet 
spec designers in their wisdom thought that they needed to invent yet 
another wildcard scheme).
But rather, about how Tomcat takes all these  sections 
of all the servlets, and then decides, when a request comes in, to which 
of the servlets it attributes the request.


Does it work as follows ?

When the various webapps are loaded (started ?), Tomcat collects all the 
's of all the webapps.
It then sorts them by length (longest first), independently of the 
webapp from whence they come.
When a request comes in, Tomcat compares the request URI with the first 
URL-pattern. If it matches, Tomcat delegates the request to the 
corresponding webapp.

If not, it checks the next pattern in the table, etc..
If the request URI does not match any url-pattern, Tomcat delegates the 
request to the "default webapp".


As a corollary to the above : whenever a webapp is stopped (unloaded?) 
or a new webapp is started (loaded ?), Tomcat for a while stops 
processing new requests and rebuilds this entire sorted url-pattern 
matching table.


As another corollary : the webapp called ROOT always has a url-pattern 
of "/", which because it is the shortest is always at the end of the 
table, and thus matches anything that does not match something else ?


Then, assuming the above is generaly correct, there is a remaining 
question about the interpretation of "length" in terms of a url-pattern.
Such as, how is the length compared between patterns like "/myservlet*" 
and "*.myservlet" ?


Thanks for some light in the matter.




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