Re: Tomcat mapping of URLs - servlets
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]
Re: Tomcat mapping of URLs - servlets
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 url-pattern 2) the appropriate servlet *within* the webapp is selected based on the url-pattern and 3) .. each webapp has a default servlet, to which things get mapped when no other url-pattern of this webapp matches 4) the ROOT webapp matches the path /, not the url-pattern / 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 ? 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
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 trtdRequestURL/tdtd%= request.getRequestURL() %/td/tr trtdRequestURI/tdtd%= request.getRequestURI() %/td/tr trtdContextPath/tdtd%= request.getContextPath() %/td/tr trtdServletPath/tdtd%= 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]
RE: Tomcat mapping of URLs - servlets
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
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
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 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 trtdRequestURL/tdtd%= request.getRequestURL() %/td/tr trtdRequestURI/tdtd%= request.getRequestURI() %/td/tr trtdContextPath/tdtd%= request.getContextPath() %/td/tr trtdServletPath/tdtd%= request.getServletPath() %/td/tr /table /body /html 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
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
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_d403854b71d795ea3a31917ee8f68382TicketId=nodzAVkWRHd5l%2BIvkk6ZUZmZdA%3D%3DGroupName=CDSFilePath=_ESD34_JSCDL_servlet_2.5-mrel2_servlet-2_5-mrel2-spec.pdfFile=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
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
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
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
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 ee8f68382TicketId=nodzAVkWRHd5l%2BIvkk6ZUZmZdA%3D%3DGroupNam e=CDSFilePath=_ESD34_JSCDL_servlet_2.5-mrel2_servlet-2_5-mrel 2-spec.pdfFile=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
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: Tomcat mapping of URLs - servlets
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 Host's appBase along with any Context 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
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 Host's appBase along with any Context 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 Context 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
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 Host's appBase along with any Context 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 Context 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
From: André Warnier [mailto:[EMAIL PROTECTED] Subject: Re: Tomcat mapping of URLs - servlets Except if there was, for /foo/bar, an appropriate Context 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]