> From: vibhuti [mailto:[EMAIL PROTECTED] > Subject: RE: Setting context in tomcat6 > > If what is written in tomcat docs is not inconsistent > then why I am not able to set an explicit context for > my web application by the following entries in myapp.xml > (placed at /conf/Catalina/localhost)
You're using the word "context" rather ambiguously; do you mean path, docBase, or what? > <Context path="" docBase="myapp" debug="0" privileged="true" /> As the doc specifically states, the default webapp must be named ROOT, and the path attribute is ignored unless the <Context> element is in server.xml, which is very strongly discouraged. > but it is the path attribute, where we specify the context we > want to use for our web application. Not any more; that went away with Tomcat 4. For Tomcat 5 and above, you specify the URL path via the name of the webapp or the name of the .xml file in the conf/Catalina/[host] directory. > Also, it is the docbase attribute that specifies, > for which web application (present under appBase > folder) will the context apply. No; if the webapp is deployed under the <Host> appBase directory, the docBase attribute isn't used. The only time docBase is useful is if the webapp is placed somewhere other than under appBase. > I have been trying to understand how to explicitly define > contexts in tomcat, read tomcat docs and searched a lot > on net but none seems to provide me complete understanding > of it. Again assuming by "context" you mean URL path, it's very simple: normally, the name of the webapp directory or .war file is the URL path. If that's not adequate, you may specify the URL path by placing a <Context> element in a file called [appName].xml under the conf/Catalina/[host] directory; the [appName] is then used as the URL path. Should you take the latter approach, the webapp must be located in [appBase]/[appName], or it must be somewhere other than under [appBase] and a docBase attribute is required in the <Context> element. > 1. Trying to set explicit context using myapp.xml placed under > (/conf/Catalina/localhost) doesn't set the context. Because the path attribute is not allowed. > 2. We can also set context using server.xml but tomcat > docs strongly recommend not to se it. > But what are the drawbacks of this approach? You have to restart Tomcat anytime you want to change attributes of the webapp. The simplest place to keep the <Context> element (if you need one at all) is in the webapp's META-INF/context.xml file, so it is packaged with the webapp. > 3. Placing context.xml in META-INF folder also doesn't set > the context. Correct; again, the name of the webapp is the URL path to it. > Is there any other way also to set explicit contexts? Not really. Name your webapp properly and you won't have a problem. Just follow the standard practice. - 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]