Tomcat - default context question..

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • SPG

    Tomcat - default context question..

    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


    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


  • Rob

    #2
    Re: Tomcat - default context question..

    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.StandardH ost"
    appBase="webapp s/myCompany/myProduct/v1_0" autoDeploy="fal se"
    configClass="or g.apache.catali na.startup.Cont extConfig"
    contextClass="o rg.apache.catal ina.core.Standa rdContext" debug="9"
    deployXML="fals e"
    errorReportValv eClass="org.apa che.catalina.va lves.ErrorRepor tValve"
    liveDeploy="fal se" mapperClass="or g.apache.catali na.core.Standar dHostMapper"
    name="v10.serve rname.com" unpackWARs="fal se">
    <Context className="org. apache.catalina .core.StandardC ontext"
    cachingAllowed= "true"
    charsetMapperCl ass="org.apache .catalina.util. CharsetMapper" cookies="true"
    crossContext="f alse" debug="9" displayName="To mcat Manager Application"
    docBase="/usr/local/tomcat4/server/webapps/manager"
    mapperClass="or g.apache.catali na.core.Standar dContextMapper" path="/manager"
    privileged="tru e" reloadable="fal se" swallowOutput=" false" useNaming="fals e"
    wrapperClass="o rg.apache.catal ina.core.Standa rdWrapper">
    <ResourceEnvRef >
    <name>users</name>
    <type>org.apach e.catalina.User Database</type>
    </ResourceEnvRef>
    <ResourceLink global="UserDat abase" name="product_u sers" type=""/>
    </Context>
    <Context className="org. apache.catalina .core.StandardC ontext"
    cachingAllowed= "true"
    charsetMapperCl ass="org.apache .catalina.util. CharsetMapper" cookies="true"
    crossContext="f alse" debug="9" displayName="My Product v1.0" docBase="ROOT"
    mapperClass="or g.apache.catali na.core.Standar dContextMapper" path=""
    privileged="fal se" reloadable="fal se" swallowOutput=" false"
    useNaming="fals e" wrapperClass="o rg.apache.catal ina.core.Standa rdWrapper">
    </Context>
    <Logger className="org. apache.catalina .logger.FileLog ger" debug="9"
    directory="logs " prefix="v10_ser vername_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" <steve.goodsell @nopoo.blueyond er.co.uk> wrote in message
    news:DnLYb.1947 $Mt5.18614293@n ews-text.cableinet. net...[color=blue]
    > 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[/color]
    about[color=blue]
    > 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[/color]
    a[color=blue]
    > bit sketchy.. or am I looking in the wrong place?
    > (http://jakarta.apache.org/tomcat/tom...fig/index.html)
    >
    > Cheers,
    >
    > Steve
    >
    >
    >[/color]


    Comment

    Working...