Meaningless Drivel is fun!
The moose likes Tomcat and the fly likes Tomcat: How can change root context and extracted files? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Tomcat: How can change root context and extracted files?" Watch "Tomcat: How can change root context and extracted files?" New topic

Tomcat: How can change root context and extracted files?

Felipe Garcia

Joined: Oct 19, 2010
Posts: 2


I'm beginning with the use of tomcat5/6.

Suppossing I've this:


Supponse I have a "appli1.war" for deploying.

Two questions:
1 - How can I configure Tomcat for the .war to be put in
but undeploy it to
/applications/application1/web (instead of /opt/tomcat6/webapps/appli1/)

2 - How can I configure Tomcat to change root context for that application so instead of accesing with:
acces with a different root context.
(really only need one accessing way, but can change depending of the application).

Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17421

Tomcat can host multiple applications. Each application is contained in its own independent WAR. A WAR is technically a ZIP (JAR) file, although Tomcat also supports "exploded WARSs", which is what you get when you unzip a WAR. Each application is associated with a URL fragment known as the "context". It's the part of the URL that immediately follows the protocol/host/port part of the URL. The root context is simply the context whose value is "/". By default, Tomcat already has an application associated with that context, but it can be replaced with one of your own applications.

When an application is deployed, the determination of which application (and therefore which WAR) will be handed an incoming URL request is made. The actual mapping of context paths to WARs follows a set of rules defined in the Tomcat docs. Although many people just use the basic default rule, which says that if you drop a WAR into TOMCAT_HOME/webapps, the basename of the WAR will be used as the context path (except for the "/" context, which goes under "ROOT"), this isn't the only way to do things. My apps typically require external configuration, so I define a context file in TOMCAT_HOME/conf/Catalina/localhost. The actual WAR I then generally place in an external directory.

An IDE is no substitute for an Intelligent Developer.
Felipe Garcia

Joined: Oct 19, 2010
Posts: 2

Thank you for your reply, but don't understand the answer, probably, because I've not detaild it fine:

What I try:

1- An application which I call "appli1". I've a "appli1.war" which I put in
I restart tomcat6 and I've:
/opt/tomcat6/webapps/appli1.war (what I've put)
/opt/tomcat6/webapps/appli1/(directory of application)

What I try is to change
/opt/tomcat6/webapps/appli1/(directory of application)
/applications/appli1/(directory of application) <-- That tomcat extract file here.

2- When I deploy the application, the url of the application is:
I what to acces with a different url.

I suppose I've to change some configuration files, but don't know where an what variables.
Can tell me what files and what variables do I've to change?


I agree. Here's the link:
subject: Tomcat: How can change root context and extracted files?
It's not a secret anymore!