Tanvir Hossain Khan
Tanvir Hossain Khan

Reputation: 537

How to set up tomcat context path for web application? .war file name is coming infront of the application name in the url

I am having a trouble getting my web application 'xyz' running in tomcat 7 server hosted in DigitalOcean servers at:

http://myDomain:8080/myWebApp

The name of my .war file is ".MyWebApp".

after deploying the .war file in tomcat, the application starts at:

http://myDomain:8080/MyWebApp/myWebApp

any idea how to remove this "MyWebApp" part from the URL?

I have seen some of the solutions for this problem, they are mostly solutions of running the application in localhost. They suggested to change the 'context.xml' file which I already did like this:

<?xml version='1.0' encoding='utf-8'?>
<Context>

    <!-- Default set of monitored resources -->
    <WatchedResource>WEB-INF/web.xml</WatchedResource>
    <WatchedResource>${catalina.base}/conf/web.xml</WatchedResource>

     path="" docBase="MyWebApp" debug="0" reloadable="true"
</Context>

Any help would be very much appreciated!

Do not mark this as duplicate. I have checked all the solutions which worked for me in localhost, but not in digital ocean VPS. I think I am pretty specific here.

Thank you in advance!

Upvotes: 5

Views: 11420

Answers (2)

Tanvir Hossain Khan
Tanvir Hossain Khan

Reputation: 537

I had to add this line in in the server.xml file. Tod do this:

nano etc/tomcat/server.xml

add this line:

 <Context path="" docBase="Advocatoree" debug="0" reloadable="true"></Context>

Save the file.

Restart tomcat.

Upvotes: 3

Malt
Malt

Reputation: 30285

The simplest way is to rename your app to ROOT.war

Not very elegant, but pretty much foolproof.

There are of course other solutions.

Upvotes: 1

Related Questions