• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to set context path in application.xml in apache tomcat?

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I want to set my application context path in application.xml in apache tomcat and I know that we can do it in server.xml too but i don't have privilege to do change in tomcat server xml files.

Please help me out like how to and where to define the context path in application.xml and where to place it in application directory.

It would be appreciated if you provide sample code.

Also please let me know if there are any other ways to declare the context path for the application rather than declaring it tomcat configuration xml files.

Thanks in advance.

Regards,
Udhay
 
Saloon Keeper
Posts: 27762
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
application.xml is part of the EAR standard. While Tomcat can do a lot of things, it's not a full-stack J2EE server and it can only work with WARs and not EARs, so you cannot use application.xml in Tomcat.

The context path can be set in the following ways, in order of precedence:

1. If a WAR has been copied into CATALINA_HOME/webapps, the context name will be the same as the WAR file name, minus the ".war" extension. So myapp.war will deploy as "myapp".

2. If a WAR has been exploded into a directory under CATALINA_HOME/webapps, the context name will be the same as the directory name. Tomcat will also ignore a WAR file with the same name, even if it is newer than the exploded WAR.

3. If the WAR includes a META-INF/context.xml file, that file will be parsed as a Tomcat Context and the context path should be obtained from there.

4. If an xml Tomcat Context file with the extension ".xml" is placed in the CATALINA_HOME/conf/Catalina/localhost directory, the context will be the name of that file minus the ".xml" extension. The context path inside the Context file is ignored. Or at least that's how Tomcat 6 is doing it.

5. If you place a Context in server.xml... DON'T put Contexts in server.xml!!!

These rules are subject to slight variations depending on the server configuration, especially rule #4, which can have multiple context directories if multiple Hosts have been configured. However, this is the "out of the box" behavior as of Tomcat 6.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic