This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Functional Reactive Programming and have Stephen Blackheath and Anthony Jones on-line!
See this thread for details.
Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
udhayan kumar
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • 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
 
Tim Holloway
Saloon Keeper
Posts: 18302
56
Android Eclipse IDE Linux
  • Likes 1
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic