Skip to content

Instantly share code, notes, and snippets.

@ae6rt
Created September 11, 2012 11:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save ae6rt/3697746 to your computer and use it in GitHub Desktop.
Save ae6rt/3697746 to your computer and use it in GitHub Desktop.
The four ways to deploy a webapp to Tomcat
There are four different ways one can deploy a webapp to Tomcat. If TCHOME is the Tomcat top-level directory:
* Copy the war file foo.war or exploded war directory to TCHOME/webapps
* Create a context file context.xml in the webapp’s META-INF/ directory that contains a <Context> fragment that describes the webapp deployment
* Add a <Context> element to the <Host> element in Tomcat’s server.xml that describes the webapp deployment, including docBase. docBase is a <Context> attribute that locates the war file or exploded war directory in the filesystem.
* Create a context file foo.xml in TCHOME/conf/Catalina/localhost/foo.xml that contains a <Context> fragment that describes the webapp deployment, including docBase.
The first two methods do not provide the freedom to name the servlet context independent of file system names for the war file or exploded war directory, whereas the last two do. Of the two methods that provide control over context naming, the most appealing is the use of a context file foo.xml placed in TCHOME/conf/Catalina/localhost/foo.xml, as it avoids modifying the stock server.xml file for pure context deployment purposes. For the root context “/”, the context file name is ROOT.xml.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment