Deploy the war file on Tomcat and run without a project name

I just created a war file of my web project (JSP / Servlets).

Project Name: TestApp

when I talk about it in Tomcat 7, I run it like this:

localhost: 8080 / TestApp / or www.maypage.com/testApp/

ok, everything works, but I need to run it without a project name, for example:

localhost: 8080 and hosted at www.maypage.com

How can i do this? thanks.

And I omit the jsp / servlet hosting that has this configuration parameter. Do you know what hosting is?

+4
source share
1 answer

To access your application without using the application name, you need to deploy it as the root application. There are several ways to achieve it, and the corresponding answer describes it pretty well.

Installing the default application in tomcat 7

Content copied from the above link:

First method:

first turn off your tomcat [from the bin directory (sh shutdown.sh)] then you must delete the entire contents of your tomapat webapps folder (rm -fr *), then rename your WAR file to ROOT.war, finally start your tomcat [from the directory bin (sh startup.sh)]

Second method:

leave your military file in CATALINA_BASE / webapps under its original name - disable autoDeploy and deployOnStartup in your Host element in the server.xml file. Explicitly define all application contexts in server.xml by specifying both paths and docBase. You must do this because you have disabled all Tomcat auto-deployment mechanisms and Tomcat will no longer deploy your applications if it does not find their Context in server.xml.

Note:

that this last method also implies that in order to make any changes to any application, you will have to stop and restart Tomcat.

Third method:

Place your war file outside of CATALINA_BASE / webapps (this should be outside to prevent double deployment). - Place the context file named ROOT.xml in CATALINA_BASE / conf //. The only element in this context MUST have a docBase attribute indicating the location of your war file. The path element must not be set - it is derived from the name of the .xml file, in this case ROOT.xml. See Context Container above for details.

+5
source

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


All Articles