'Change tomcats default URL

I have 2 runnings tomcats (version 8). 1 is reachable via http://localhost:8080/ . All other apps of this tomcat are reachable as expected on:

The second tomcat is reachable via http://localhost:9090/ . (Other port) But I need an other difference. I would like to change the URL prePath like the following:

I tried a lot with Context element in server.xml and context.xml. But nothing meets my requirement.

I would like to have a path prefix, also for the ROOT as http://localhost:9090/test/ .

I don't know how to, so does someone knows a good solution for this?



Solution 1:[1]

One simple solution would be to deploy all relevant applications under a test folder.

e.g. move tomcat-${version}/webapps/examples to tomcat-${version}/webapps/test/examples.

You can also copy the contents of the ROOT folder into the newly created test folder to achieve the same ROOT functionality for http://localhost:9090/test.

Solution 2:[2]

I solved the problem with tomcats manager directory/folder that I renamed it to "test#manager" and my Application will be now deployed as "test#myApp.war" to directory/folder: "test#myApp".

Now I can reach the manager with http://localhost:9090/test/manager and my App with http://localhost:9090/test/myApp.

So to get a default URL for manager, examples and apps you can go with renaming the folders as described. To get a default url of the root you have to go as #Boo Radley described in the other answer.

There is no new folder necessary. Start, Stop, Deploy and Undeploy webapps should work.

Background: You can give directories a context with a prefix like "yourContext#" to the given directory or .war described at https://tomcat.apache.org/tomcat-8.0-doc/config/context.html in table of examples in (Introduction -> 2. Naming) section.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 Alexander Plickat