jQuery in Action, 2nd edition*
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
Author

Replacing the root context

Stef Mischook
Greenhorn

Joined: Nov 12, 2004
Posts: 15
Hi,

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

http://127.0.0.1/mywebsite/

Rather I want this:

http://127.0.0.1/

Thanks,

S


<a href="http://www.killersites.com" target="_blank" rel="nofollow">http://www.killersites.com</a><br /><a href="http://www.how-to-build-websites.com" target="_blank" rel="nofollow">http://www.how-to-build-websites.com</a><br /><a href="http://www.websitetemplates.name" target="_blank" rel="nofollow">http://www.websitetemplates.name</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.

http://jakarta.apache.org/tomcat/tomcat-5.0-doc/config/context.html

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!

Jimbus
[ December 07, 2004: Message edited by: Jim Babcock ]
 
jQuery in Action, 2nd edition
 
subject: Replacing the root context
 
Similar Threads
Automatic redirect to my context
question on servlet-mapping
how to deploy a web application on root of tomcat ?
Mapping JSP
how to expose defined directory under webapps