There are 3 xml files - server.xml, context.xml and web.xml in the conf directory of Tomcat.
What is the difference between them.
Also we write a web.xml for each web application and it resides in the WEB-INF directory.
Just today, i wanted to use Connection Pooling in Eclipse, and i read on the internet that we could add context.xml file in the META-INF directory of the WebContent folder in an application in Eclipse.
In this context.xml file we could specify the DataSource details in the Resource element.
Could anybody please explain the difference between all the xml files.
And also if i have to implement the connection pooling, then in which xml file should i enter the details.
To start with, every J2EE webapp has 2 deployment configuration files: the server-independent Deployment Descriptor (web.xml) and the server-dependent Deployment Descriptor (context.xml). More on this in a minute.
The Tomcat server.xml file is the configuration of the Tomcat server itself. Tomcat is actually a series of components that are wired together to create a server by a master Tomcat JavaBean that reads (digests) the server.xml file in order to know what components to include, how to configure them, and how to interconnect them to create a working server. The server.xml file can contain server-dependent deployment descriptors as sub-elements, although that has been discouraged for a long, long time now. Among other reasons, because it required restarting the entire Tomcat server to modify a single webapp.
The server-dependent deployment descriptors can reside in a directory of their own (conf/Catalina/localhost) or be embedded within a webapp's WAR (META-INF/context.xml). Incidentally, the "localhost" in the tomcat Catalina directory is merely the default. For Tomcat servers where a single Tomcat runs multiple hosts, there is a separate config directory under Catalina for each host.
So you have server.xml for Tomcat itself and a context.xml/web.xml pair for each webapp deployed in tomcat. The context.xml and web.xml in the Tomcat conf directory are used to guide the default behavior of Tomcat. For example, when you submit a URL which resolves to a static resource such as an image, Tomcat doesn't simply "know" how to convert that image URL into a response stream containing that image, it determines that the URL doesn't match any of the patterns defined in the web.xml for the webapp context ID of that URL and bounces the request up to the default environment where the Tomcat DefaultServlet takes care of the actual details of converting the URL to a resource location, opening the resource (image file) and transmitting the resource to the client. All of that is under the control of the master context and web-inf config files in the Tomcat conf directory.
Certain resources can be defined per-application or shared between multiple applications. The most common ones are security Realms and Connection Pools. When you want a per-application definition of one of those resources, you'd do it in the Context xml file. When you want it common between apps, you'd define it in the server.xml, since it's the only common configuration between all webapps. There are precedence rules when 2 definitions conflict, but those rules are enumerated in the Tomcat docs.
When it comes to destroying a civilization, gas chambers cannot hold a candle to echo chambers.
I like your answer, but I think it could be a little bit clearer. The word "server" is overloaded. Instead I think it would be better to say "tomcat instance", or "tomcat server instance", or even "tomcat http server instance". Thanks.
Please ignore post, I have no idea what I am talking about.