tomcat 6 - how to define context root name diff than WAR file name
sush dod
Greenhorn
Joined: Nov 26, 2005
Posts: 4
posted
0
HI guys i am using TOMCAT 6 to deploy a struts based application WAR file. my problem is my WAR file name is aaa.0.0.1d.WAR in dev aaa.0.0.1s.WAR in stage and aaa.0.0.1p in prod environment. for dev WAR i need to set the context root as reporting so that my request URL would be http://localhost:8090/reporting/getReport.do i tried creating a XML file as aaa.0.0.1d.xml and deployed in the CATALINA_HOME/conf/Catalina/localhost/ directory and the content of the file is
<?xml version="1.0" encoding="UTF-8"?> <!-- Context fragment for deploying the build-demo application
but as my WAR file name is aaa.0.0.1d.WAR i cant use above mentioned request URL. if i use the request URL as http://localhost:8090/aaa.0.0.1d/getReport.do then it works fine. so in short i need to define a context root which is diffrent than my application WAR name. can anybody tell me how can i do this?
First off you should use relative path names, then you wouldn't even need to worry about what the base URL is. Second, it sounds like your configuration is wrong, the WAR name does not need to be part of the URL. Are you putting the information you want in the server config or the WEB-INF/web.xml file?
what do you mean by my configuration is wrong. i can access my application using the URL http://loalhost:8090/aaa.0.0.1d/.... can you tell me how do you set the relative path in the application specific xml file?
Originally posted by sush dod: no i am not writing nything in the server.xml and even in web.xml
Stop right there. That's your problem. Context path is controlled by one of these files.
And in the words of a friend of mine "Not writing nything"? Ok first nothing is misspelled but even still "no i am not writing nothing" ... such bad grammar. [ August 19, 2008: Message edited by: Scott Selikoff ]
Karel Vervaeke
Greenhorn
Joined: Jul 20, 2004
Posts: 4
posted
0
Originally posted by Scott Selikoff:
And in the words of a friend of mine "Not writing nything"? Ok first nothing is misspelled but even still "no i am not writing nothing" ... such bad grammar. [ August 19, 2008: Message edited by: Scott Selikoff ]
The poster meant to write "anything". As a typo, "any -> ny" makes much more sense than "not -> nyt"
sush dod wrote:HI guys i am using TOMCAT 6 to deploy a struts based application WAR file.
my problem is my WAR file name is aaa.0.0.1d.WAR in dev aaa.0.0.1s.WAR in stage and aaa.0.0.1p in prod environment.
for dev WAR i need to set the context root as reporting so that my request URL would be
http://localhost:8090/reporting/getReport.do i tried creating a XML file as aaa.0.0.1d.xml and deployed in the CATALINA_HOME/conf/Catalina/localhost/ directory
and the content of the file is
<?xml version="1.0" encoding="UTF-8"?>
<!-- Context fragment for deploying the build-demo application
but as my WAR file name is aaa.0.0.1d.WAR i cant use above mentioned request URL.
if i use the request URL as
http://localhost:8090/aaa.0.0.1d/getReport.do then it works fine.
so in short i need to define a context root which is diffrent than my application WAR name.
can anybody tell me how can i do this?
If i not understood you wrong then you want to set your root web application to your default web application. meaning when you open http://localhost:8090/ then your application will be loaded. For doing this you need to just add folowing tag in server.xml tag within host tag.
Didn't adding <Context docBase="docs" path="/ZZZ" />
to server.xml deploy your application twice ? I am facing the same issue.I need the context path to be different to my WAR name.
But editing server.xml is not recommended by Tomcat and even if you do it the war is deployed twice.
subject: tomcat 6 - how to define context root name diff than WAR file name