wood burning stoves 2.0*
The moose likes Tomcat and the fly likes Context Question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Context Question" Watch "Context Question" New topic
Author

Context Question

James Ellis
Ranch Hand

Joined: Oct 14, 2004
Posts: 205
I am upgrading from Tomcat 4 to Tomcat 6, and the concept of $CATALINA_HOME/conf/context.xml is confusing to me.

If we want to have multiple web applications running on a server, how can we list these in the $CATALINA_HOME/conf/context.xml file? Every time I try and put multiple context entries in this file I get a parse error on startup. Are we only allowed to have one context entry in this file?

If so, why would anyone ever use this as opposed to putting the context.xml into META-INF under webapps?
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

See:
http://tomcat.apache.org/tomcat-6.0-doc/deployer-howto.html#A%20word%20on%20Contexts

They go in tomcat/conf/Catalina/localhost/[context-name].xml

If you have configured your own host, replace the 'Catalina/localhost' part accordingly.


... why would anyone ever use this as opposed to putting the context.xml into META-INF under webapps?


You can still place a context.xml file in your META-INF diretory if you like. Just to be clear, the META-INF directory is under webapps/[context-name]/META-INF.

When I'm developing apps, I keep the code base outside of the tomcat hierarchy. Using context fragment files makes it easy to separate the two.


Lastly, don't try to put more than one context entry in a context fragment file. Each application should have its own file named [context-name].xml


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
James Ellis
Ranch Hand

Joined: Oct 14, 2004
Posts: 205
Ben,

Thanks for the reply. Putting the context information in tomcat/conf/Catalina/localhost/[context-name].xml will work fine for me.

However I still don't understand the point of tomcat/conf/context.xml. Is this for "global" context information? Meaning you can't put docBase or path attributes in here...because the context entry applies to all contexts?

Thanks,
Jim
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Originally posted by James Ellis:
However I still don't understand the point of tomcat/conf/context.xml.

Where are you reading about this file?
James Ellis
Ranch Hand

Joined: Oct 14, 2004
Posts: 205
Ben,

I am reading about it here.

There was also already a blank tomcat/conf/context.xml already in my installation of tomcat when I unpacked the zip for Tomcat 6.0.16.

Jim
[ March 02, 2008: Message edited by: James Ellis ]
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

I see.
It says that the element information here will be shared by all web apps.
I've never used it but I'm taking that to mean that this would be a place to put settings that will be common to all of them.
The same way you can put common settings into the tomcat/conf/web.xml descriptor.
James Ellis
Ranch Hand

Joined: Oct 14, 2004
Posts: 205
Thanks Ben,

I'll be following your advice and putting the context information in tomcat/conf/Catalina/localhost/[context-name].xml

Thanks,
Jim
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Context Question
 
Similar Threads
To Author: Configuring context at web application level
deploying in tomcat 6
tomcat connection pooling
context.xml
More one context.xml in a Webapp