aspose file tools*
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
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
Author

Tomcat: How can change root context and extracted files?

Felipe Garcia
Greenhorn

Joined: Oct 19, 2010
Posts: 2


Hallo:

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

Suppossing I've this:

/applications/aplication1/staticdata
/applications/aplication1/web
/applications/aplication1/web/index.html
/applications/aplication1/web/WEB-INF/web.xml
....
/opt/tomcat6/

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

Two questions:
1 - How can I configure Tomcat for the .war to be put in
/opt/tomcat6/webapps/
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:
http://server.domain/appli1/
acces with a different root context.
Ex:
http://server.domain/application1/
or
http://server.domain/applications/appli1/
or
http://server.domain/Appli1/
(really only need one accessing way, but can change depending of the application).



Regards
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16236
    
  21

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.


Customer surveys are for companies who didn't pay proper attention to begin with.
Felipe Garcia
Greenhorn

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
/opt/tomcat6/webapps
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)
to
/applications/appli1/(directory of application) <-- That tomcat extract file here.

2- When I deploy the application, the url of the application is:
http://server.domain/appli1/
I what to acces with a different url.
Ej:
http://server.domain/applications/Appli1/

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?

Thanks



 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Tomcat: How can change root context and extracted files?