Skip navigation

Tag Archives: Tomcat

Let say that you have fresh download of Tomcat 6 and want to deploy your web application in it, but you don’t want to access your web application using URL form http://%5BIP_OR_DOMAIN_NAME%5D:%5BPORT%5D/%5BWEB_APPLICATION_NAME%5D (e.g http://localhost:8080/BlaBlaBla) instead you just want URL form http://%5BIP_OR_DOMAIN_NAME%5D:%5BPORT%5D (e.g http://localhost:8080) to access your application. There are few ways to do these that I know and I will it post here.

To deploy web application in Tomcat we can use WAR file or using webapp exploded directory, I will use the last one. You can deploy your webapp in “TOMCAT_HOME/webapps” directory or outside of Tomcat directory, I will use last one also. Now let see how to change Tomcat 6 ROOT context:

Trick 1
Open “TOMCAT_HOME\conf\server.xml” file, look for Host tag, add Context tag to it so it will looks something like these:

<Host name="localhost"  appBase="webapps"
            unpackWARs="true" autoDeploy="true"
            xmlValidation="false" xmlNamespaceAware="false">
        ............
        ............
	<Context path="" docBase="D:\Gardiary\temp\my-app" reloadable="true" debug="0" cookies="false"></Context>
</Host>

Note that Context path is set to  “” not “/” and docBase is path to your webapp exploded directory. Save it and run your Tomcat,  you should be able to access your application just by using http://localhost:8080.

Trick 2
Remove (or change to other name) “TOMCAT_HOME\webapps\ROOT” folder, rename your webapp to ROOT and then put it in “TOMCAT_HOME\webapps” folder (a.k.a change the content of original ROOT folder with your web application content). Run your Tomcat.

Trick 3
Create file “TOMCAT_HOME\conf\Catalina\localhost\ROOT.xml“, the file looks something like these:

<?xml version="1.0" encoding="UTF-8"?>
<Context docBase="D:\Gardiary\temp\my-app"
 crossContext="true" reloadable="true">
</Context>

Change docBase to your webapp exploded directory and then run your tomcat.

That’s all I know folks!