This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Tomcat and the fly likes Context Root in WEB.XML Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Context Root in WEB.XML" Watch "Context Root in WEB.XML" New topic
Author

Context Root in WEB.XML

Shiaber Shaam
Ranch Hand

Joined: Jun 16, 2006
Posts: 252
Please let me know the syntax for setting Contect Root in Web.xml. Thanks.


$Hi/\bEr
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61448
    
  67

The context root is not set in the web.xml. It's set by how you deploy the web app in your container. Your web app itself has (or should have) no knowledge of what the actually context path will be.

If you've hard-coded the context path anywhere within your web app, you've done it wrong.

And it's web.xml, not Web.xml or WEB.XML. Case counts.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Shiaber Shaam
Ranch Hand

Joined: Jun 16, 2006
Posts: 252
Thanks. I want to know a generic way to configure context root. As i am using tomcat in my dev and wl 10.3 in a test env. Please clarify.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61448
    
  67

I have moved this to the Tomcat forum.

Please reference the Tomcat documentation on how to deploy web apps. It's pretty easy.

Post back with question you might have.
Shiaber Shaam
Ranch Hand

Joined: Jun 16, 2006
Posts: 252
Please let me know the way to set the context root irrespective of the server/container.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61448
    
  67

There is no way. Each container has its own means of setting up web apps. You'll need to follow the rules of the specific container that you are using.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16158
    
  21

J2EE defines 2 separate sources for deployment information. One is web.xml. One is container-dependent, and is usually, but not always an XML file. It's format and content is defined by the application server provider. You can find out details on this under the JSR-88 spec.

Tomcat's deployment descriptor is the <Context> element which can be defined in Tomcat's server.xml (please don't), an XML file in Tomcat's conf/Catalina/localhost directory, or in the WAR as a file named context.xml. Container-supplied definitions will override context.xml.

ONLY Tomcat and product with embedded Tomcat (like JBoss) use this context.xml file. Products such as IBM's WebSphere have their own deployment descriptor file names and formats.


Customer surveys are for companies who didn't pay proper attention to begin with.
 
jQuery in Action, 2nd edition
 
subject: Context Root in WEB.XML