permaculture playing cards*
The moose likes Tomcat and the fly likes How to set context path in application.xml in apache tomcat? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "How to set context path in application.xml in apache tomcat?" Watch "How to set context path in application.xml in apache tomcat?" New topic
Author

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

udhayan kumar
Greenhorn

Joined: Jan 28, 2010
Posts: 16
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

Joined: Jun 25, 2001
Posts: 16065
    
  21

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.


Customer surveys are for companies who didn't pay proper attention to begin with.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to set context path in application.xml in apache tomcat?