How to configure my webapp as ROOT for localhost: 8080

I have a webapp in my Tomcat / webapps directory. My application directory is a "site" and appears as http: localhost: 8080 / site

I would like the site to show as http: // localhost: 8080 /

I read the docs and tried to create the ROOT.xml file in the Tomcat / conf / Catalina / localhost directory to create the path to the ROOT content, but the connection fails.

Can someone push me in the right direction? Here is the contents of this ROOT.xml file.

<Context docBase="site" path="/"> </Context> 
+4
source share
1 answer

The easiest way to get the root context is to simply rename the application directory from webapps/site to webapps/ROOT and restart Tomcat. If your default webapps already has a ROOT application, you need to create another node, because there can only be one root context application per host.

Another option (again, if you do not already have a ROOT application under webapps ), you should edit your conf/server.xml file and add your context element to the default <Host> :

 <Context path="" docBase="site" /> 

If you want to create a separate host, you will need to define the second <Host> in server.xml , for example,

 <Host name="anotherhost" appBase="webapps_anotherhost"></Host> 

To accomplish the above, you need to create the webapps_anotherhost folder as a sibling folder next to your main webapps folder and then leave the WAR in this folder either as an exploded directory named ROOT or a compressed WAR named ROOT.war . Then restart Tomcat and view the application at http://anotherhost:8080 (of course, you can also specify the file with the host files).

These are just a few of the many options. Tomcat docs describe this stuff in some detail. You can find documents for your version of Tomcat at http://tomcat.apache.org/ .

+5
source

Source: https://habr.com/ru/post/1348162/


All Articles