Skip navigation

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>

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">

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

That’s all I know folks!

One Comment

  1. Hello,

    I had session error while using Tomcat 6.0.43, with the Trick 1

    To solve the same I had edited trick 1 line:

    And edited cookies from ‘false’ to ‘true’. Also I changed the application path to outside of {Catalina_Home}/webapps folder.

One Trackback/Pingback

  1. By | The RoboColum(n) on 23 Jan 2013 at 4:57 pm

    […] than http://localhost:8080/ to access the application.      My issue here is that I am struggling to see why you would want to do this, particularly if you […]

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: