File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Tomcat and the fly likes Replacing the root context Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Replacing the root context" Watch "Replacing the root context" New topic

Replacing the root context

Stef Mischook

Joined: Nov 12, 2004
Posts: 15

I want to replace Tomcats root application with my own so that I don't have to have this URL:

Rather I want this:



<a href="" target="_blank" rel="nofollow"></a><br /><a href="" target="_blank" rel="nofollow"></a><br /><a href="" target="_blank" rel="nofollow"></a>
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

Is there a question?

But seriously... you want to replace the existing "default application" with yours.

3rd paragraph makes reference to the default application. You should be able to find it in server.xml
Jim Babcock
Ranch Hand

Joined: Dec 03, 2004
Posts: 55
Try looking in at the application you are answering for before giving snotty answers. Some of us look at the documentation before we ask questions, thank you very much.

There is no default context defined in a bare tomcat installation, there is only the server, service and host. The host has an appBase defined as TOMCAT_BASE/webapps and by default the defaultcontext has its path set to "ROOT". I looked everywhere I could think of and could not find "ROOT" defined in an XML file... I suspect its a hard coded default in a class somewhere (kind of cheesy if true .

I've been struggling with this for more than a week and have see the question, unanswered, on almost every forum I've checked... but I figured it out, today.

Reading the config and the docs, they say they no longer want you put Contexts in server.xml. Tomcat builds a directory structure based on Severice and Host in conf (Catalina/localhost) and thats where you'll find the XML configs for admin, balancer and jsp-examples. All of your applications should build context files here. You can put a DefalutContext in your server.xml, but there is apparently no docBase as in a regular Context, so that doesn't help move "/" to a alternate directory tree.

I tried moving the Host's appBase to point where I wanted, but that broke everything. I was trying that today and noticed that the "admin/" still worked, even when "/" did not and that pointed me to my answer.

Find admin.xml, copy it into a file named default.xml (actual name is not important). Edit the file, change the path from "admin/" to "/" and change the docBase to where you want to point to (I used /usr/home/appadmin/deck/production) and voila! You'll still have to make sure your WEB_INF and such are in the right spots, but that works for me.

Have Fun!

[ December 07, 2004: Message edited by: Jim Babcock ]
I agree. Here's the link:
subject: Replacing the root context
jQuery in Action, 3rd edition