471,310 Members | 1,375 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,310 software developers and data experts.

Tomcat - default context question..

SPG
Hi,

I am relatively new to TOMCAT, and am trying to deploy a web app using it.
I have a domain name that I want to use to access my web app directly.
By default, I deploy my WAR, and it deploys to webapps/myApp.

To access this I have to use a url like
http://mydomain.com/myApp?someparam=1

What I want to do is use this: http://mydomain.com?someparam=1

I have used the CONTEXT element in the server.xml file, but that seems to
cause some funny things..

<CONTEXT PATH="/" docbase="/myApp"/>

I have tried to find mor einfo about this, and have seen some mention about
using a 'DEFAULT CONTEXT" setting..
Is there anyone who knows how I can do this? And can someone point me to
some decent documentation on the serverlxml file? (The jakarta site seems a
bit sketchy.. or am I looking in the wrong place?
(http://jakarta.apache.org/tomcat/tom...fig/index.html)

Cheers,

Steve
Jul 17 '05 #1
1 10094
Rob
Hi Steve,

I use Tomcat4 and I remember when I encountered the same problem that you
describe. Tomcat4, in my experience, only likes a root context (context
path="/") in a directory called ROOT. Since you already have a ROOT context
(and directory) in your localhost (the default tomcat page with links to the
manager and admin apps), you should define a separate Host and work with
that. That way, if you have requests to localhost's Root Context, it'll go
to the default page, and any requests for your new Host's Root Context will
go to its appropriate place. I'll attach a snippet of the server.xml file
that will show you how you can define a new Host, and also how you can
install the Manager App for that Host (to make it easier to start, stop,
restart, etc):

<Host className="org.apache.catalina.core.StandardHost"
appBase="webapps/myCompany/myProduct/v1_0" autoDeploy="false"
configClass="org.apache.catalina.startup.ContextCo nfig"
contextClass="org.apache.catalina.core.StandardCon text" debug="9"
deployXML="false"
errorReportValveClass="org.apache.catalina.valves. ErrorReportValve"
liveDeploy="false" mapperClass="org.apache.catalina.core.StandardHost Mapper"
name="v10.servername.com" unpackWARs="false">
<Context className="org.apache.catalina.core.StandardContex t"
cachingAllowed="true"
charsetMapperClass="org.apache.catalina.util.Chars etMapper" cookies="true"
crossContext="false" debug="9" displayName="Tomcat Manager Application"
docBase="/usr/local/tomcat4/server/webapps/manager"
mapperClass="org.apache.catalina.core.StandardCont extMapper" path="/manager"
privileged="true" reloadable="false" swallowOutput="false" useNaming="false"
wrapperClass="org.apache.catalina.core.StandardWra pper">
<ResourceEnvRef>
<name>users</name>
<type>org.apache.catalina.UserDatabase</type>
</ResourceEnvRef>
<ResourceLink global="UserDatabase" name="product_users" type=""/>
</Context>
<Context className="org.apache.catalina.core.StandardContex t"
cachingAllowed="true"
charsetMapperClass="org.apache.catalina.util.Chars etMapper" cookies="true"
crossContext="false" debug="9" displayName="My Product v1.0" docBase="ROOT"
mapperClass="org.apache.catalina.core.StandardCont extMapper" path=""
privileged="false" reloadable="false" swallowOutput="false"
useNaming="false" wrapperClass="org.apache.catalina.core.StandardWra pper">
</Context>
<Logger className="org.apache.catalina.logger.FileLogger" debug="9"
directory="logs" prefix="v10_servername_com_log." suffix=".txt"
timestamp="true" verbosity="4"/>
</Host>

Obviously, all the values are adjustable for your own situation. You can
see that my ROOT directory for this Host's Root Context is actually found at
$CATALINA_HOME/webapps/myCompany/myProduct/v1_0/ROOT.

You should note, also, that if your "servername.com" isn't an official DNS
entry, you'll need to make an entry for it in your HOSTS file, so your
computer knows the ip of the Host you're defining (sorry if you already know
this!!). In my example above, I would put "<<IP Address>>
v10.servername.com" in my HOSTS file, and the appropriate page will be
served.

Hope this helps,
Rob

"SPG" <st************@nopoo.blueyonder.co.uk> wrote in message
news:Dn*********************@news-text.cableinet.net...
Hi,

I am relatively new to TOMCAT, and am trying to deploy a web app using it.
I have a domain name that I want to use to access my web app directly.
By default, I deploy my WAR, and it deploys to webapps/myApp.

To access this I have to use a url like
http://mydomain.com/myApp?someparam=1

What I want to do is use this: http://mydomain.com?someparam=1

I have used the CONTEXT element in the server.xml file, but that seems to
cause some funny things..

<CONTEXT PATH="/" docbase="/myApp"/>

I have tried to find mor einfo about this, and have seen some mention about using a 'DEFAULT CONTEXT" setting..
Is there anyone who knows how I can do this? And can someone point me to
some decent documentation on the serverlxml file? (The jakarta site seems a bit sketchy.. or am I looking in the wrong place?
(http://jakarta.apache.org/tomcat/tom...fig/index.html)

Cheers,

Steve

Jul 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by joes | last post: by
2 posts views Thread by devu | last post: by
5 posts views Thread by Tom Martin | last post: by
1 post views Thread by Oliver Hoehle | last post: by
2 posts views Thread by Wired Earp | last post: by
4 posts views Thread by jesper | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.