Thank you so much for the prompt reply and answering all the questions so
well. I thought "context" and URL path mean the same. I apologize if this
caused confusion. In my mails wherever I wrote "context" I meant "URL path".


Now I believe I understand how url paths are set in tomcat. Either using
name of the web application or using [appname].xml file placed at
/conf/Catalina/[host] location are the only ways to specify the URL path of
a web application. The approach I was trying to use worked with tomcat4, it
some how worked with tomcat5 and I was trying to apply it to tomcat 6 also
which was wrong.

So one question remains; if I want that URL http://localhost:8080/ should
redirect user to the home page of my application then what should I do? I
mean I don't want the tomcat home page to be displayed.

One more query I have regarding the description you gave about defining
<Context> element in server.xml. You wrote:
"You have to restart Tomcat anytime you want to change attributes of the
webapp."
What does attribute of web application exactly mean? If there are no changes
made to the application attributes then can we use <Context> element in
server.xml or using a <Context> element in server.xml will have some adverse
effects on the way web application behaves. 

Thanks



-----Original Message-----
From: Caldarale, Charles R [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, July 23, 2008 11:55 AM
To: Tomcat Users List
Subject: RE: Setting context in tomcat6

> 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]



---------------------------------------------------------------------
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