I'm trying to change the default application of a Tomcat 6 webserver to a different application than "ROOT" (inside webapps folder). What is the best way to do this?
I'm trying to change the default application of a Tomcat 6 webserver to a different application than "ROOT" (inside webapps folder). What is the best way to do this?
Adding a <Context> tag in the <Host> tag in server.xml for Tomcat 6 will resolve the problem.
If you use path="" empty you can use a URL like http://localhost/first.do.
In the context tag set attributes docBase="E:\struts-ITRCbook\myStrutsbook" and reloadable="true", then end the context tag.
It should look something like this:
<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">
<Context path="" docBase="E:\struts-ITRCbook\myStrutsbook" reloadable="true">
</Context>
</Host>
You can do this in a slightly hack-y way by:
According to the Apache Tomcat docs, you can change the application by creating a ROOT.xml file. See this for more info:
http://tomcat.apache.org/tomcat-6.0-doc/config/context.html
"The default web application may be defined by using a file called ROOT.xml."
the context.xml configuration didn't work for me. Tomcat 6.0.29 complains about the docBase being inside the appBase: ... For Tomcat 5 this did actually work.
So one solution is to put the application in the ROOT folder.
Another very simple solution is to put an index.jsp to ROOT that redirects to my application like this: response.sendRedirect("/MyApplicationXy");
Best Regards, Jan
Ultimate way to change tomcat root application. Tested on Tomcat 7 and 8.
Move to the tomcat webapps directory:
Example on my machine: ~/stack/apache-tomcat/webapps
Rename, replace or delete ROOT folder. My advice is renaming or create a copy for backup. Example rename ROOT to RENAMED_ROOT:
mv ROOT RENAMED_ROOT
Move war file with your application to tomcat webapps directory (its a directory where was old ROOT folder, on my machine: ~/stack/apache-tomcat/webapps)
War file must have a name ROOT.war. Rename your aplication if it's need: yourApplicationName.war -> ROOT.war
I'll look at my docs; there's a way of specifying a configuration to change the path of the root web application away from ROOT (or ROOT.war), but it seems to have changed between Tomcat 5 and 6.
Found this:
http://www.nabble.com/Re:-Tomcat-6-and-ROOT-application...-td20017401.html
So, it seems that changing the root path (in ROOT.xml) is possible, but a bit broken -- you need to move your WAR outside of the auto-deployment directory. Mind if I ask why just renaming your file to ROOT.war isn't a workable solution?