What version of Tomcat are you using?
I've been using Tomcat 6 and 7 for a while, and now running Tomcat 8.

it is recommended that <Context> elements not be placed directly in server.xml
I know, but it is much easier for me to edit a single file, server.xml then deploy all the other files. I'm looking to keep the deployment process as simple as possible.

you shouldn't need the empty directory. I've used an absolute path for the <Host> appBase attribute with relative paths for <Context> docBase attributes in Tomcat 6 and 7 without any problems.
when I try that then "webapps" is used by default. if a request is made for a file that exists in webapps, e.g. index.jsp and does not exist in my application's folder, then it is served from webapps and I don't want that.

are you sure you want "/" for the <Context> path attribute in the first example above?
it was my understanding that "" and "/" are the same here. "/" reads more clearly to me as the "root" directory so I prefer to use that.

*after reading your email and testing it, however, I noticed that if I omit the Host/appBase and use an empty-string for the Context/docBase/path it works as intended, so maybe that's what I was doing wrong? is that the best practice?*

<Host name="Site1" unpackWARs="false" autoDeploy="false">
  <Context path="" docBase="D:/www/site1" />
  <Context path="/virtualdir" docBase="D:/www/shared/virtualdir" />
</Host>

?

thank you both for your responses,


Igal


On 7/5/2014 9:48 AM, Terence M. Bandoian wrote:
On 7/4/2014 9:04 PM, Igal @ getRailo.org wrote:
I'm a little confused about the Host appBase attribute.

Let's say that my website resides in D:\www\site1

I don't like using {Tomcat}/webapps so I don't want to have it as a base directory for websites. What I've been doing so far is create an empty folder alongside "webapps", named "empty", and use it as appBase, e.g.

<Host name="Site1" appBase="empty" unpackWARs="false" autoDeploy="false">
  <!-- this works but what's the deal with appBase? !-->
  <Context path="/" docBase="D:/www/site1" />
</Host>

But it feels like I'm doing something wrong. I expect this to work, but it doesn't:

<Host name="Site1" appBase="D:/www/site1" unpackWARs="false" autoDeploy="false">
  <!-- this doesn't work !-->
</Host>

Can anyone explain why the snippet above doesn't work, and if that is the way it should be, then what is the purpose of Host/appBase?

TIA


Hi, Igal-

What version of Tomcat are you using? Also, it is recommended that <Context> elements not be placed directly in server.xml. See:

http://tomcat.apache.org/tomcat-7.0-doc/config/context.html#Defining_a_context

That said, you shouldn't need the empty directory. I've used an absolute path for the <Host> appBase attribute with relative paths for <Context> docBase attributes in Tomcat 6 and 7 without any problems. I haven't tried it with absolute paths for both appBase and docBase.

Lastly, are you sure you want "/" for the <Context> path attribute in the first example above? The <Context> path for the default web application of a <Host> should be an empty string (""). See:

http://tomcat.apache.org/tomcat-7.0-doc/config/context.html#Common_Attributes

-Terence Bandoian

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org


--
Igal Sapir
Railo Core Developer
http://getRailo.org/

Reply via email to