简体   繁体   中英

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!

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.

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

Not very elegant, but pretty much foolproof.

There are of course other solutions.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM